mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-26 06:47:17 +10:00
Merge pull request #586 from sharetribe/improve-tx-routing
Make auth routing more intuitive
This commit is contained in:
commit
ce75cee279
2 changed files with 46 additions and 52 deletions
|
|
@ -59,26 +59,23 @@ describe('Application', () => {
|
|||
it('server renders redirects for pages that require authentication', () => {
|
||||
const loginPath = '/login';
|
||||
const signupPath = '/signup';
|
||||
const defaultAuthPath = signupPath;
|
||||
const urlRedirects = {
|
||||
'/l/new': defaultAuthPath,
|
||||
'/l/listing-title-slug/1234/new/description': defaultAuthPath,
|
||||
'/l/listing-title-slug/1234/checkout': defaultAuthPath,
|
||||
'/profile-settings': defaultAuthPath,
|
||||
'/inbox': defaultAuthPath,
|
||||
'/inbox/orders': defaultAuthPath,
|
||||
'/inbox/sales': defaultAuthPath,
|
||||
'/order/1234': defaultAuthPath,
|
||||
'/order/1234/discussion': defaultAuthPath,
|
||||
'/order/1234/details': defaultAuthPath,
|
||||
'/sale/1234': defaultAuthPath,
|
||||
'/sale/1234/discussion': defaultAuthPath,
|
||||
'/sale/1234/details': defaultAuthPath,
|
||||
'/listings': defaultAuthPath,
|
||||
'/account': defaultAuthPath,
|
||||
'/account/contact-details': defaultAuthPath,
|
||||
'/account/change-password': defaultAuthPath,
|
||||
'/account/payout-preferences': defaultAuthPath,
|
||||
'/l/new': signupPath,
|
||||
'/l/listing-title-slug/1234/new/description': signupPath,
|
||||
'/l/listing-title-slug/1234/checkout': signupPath,
|
||||
'/profile-settings': loginPath,
|
||||
'/inbox': loginPath,
|
||||
'/inbox/orders': loginPath,
|
||||
'/inbox/sales': loginPath,
|
||||
'/order/1234': loginPath,
|
||||
'/order/1234/details': loginPath,
|
||||
'/sale/1234': loginPath,
|
||||
'/sale/1234/details': loginPath,
|
||||
'/listings': loginPath,
|
||||
'/account': loginPath,
|
||||
'/account/contact-details': loginPath,
|
||||
'/account/change-password': loginPath,
|
||||
'/account/payout-preferences': loginPath,
|
||||
'/verify-email': loginPath,
|
||||
};
|
||||
forEach(urlRedirects, (redirectPath, url) => {
|
||||
|
|
|
|||
|
|
@ -95,15 +95,15 @@ const routeConfiguration = () => {
|
|||
},
|
||||
{
|
||||
path: '/l/:slug/:id/checkout',
|
||||
auth: true,
|
||||
name: 'CheckoutPage',
|
||||
auth: true,
|
||||
component: props => <CheckoutPage {...props} />,
|
||||
setInitialValues: CheckoutPage.setInitialValues,
|
||||
},
|
||||
{
|
||||
auth: true,
|
||||
path: '/l/new',
|
||||
name: 'NewListingPage',
|
||||
auth: true,
|
||||
component: () => (
|
||||
<NamedRedirect
|
||||
name="EditListingPage"
|
||||
|
|
@ -112,9 +112,9 @@ const routeConfiguration = () => {
|
|||
),
|
||||
},
|
||||
{
|
||||
auth: true,
|
||||
path: '/l/:slug/:id/:type/:tab',
|
||||
name: 'EditListingPage',
|
||||
auth: true,
|
||||
component: props => <EditListingPage {...props} />,
|
||||
loadData: EditListingPage.loadData,
|
||||
},
|
||||
|
|
@ -140,8 +140,9 @@ const routeConfiguration = () => {
|
|||
},
|
||||
{
|
||||
path: '/profile-settings',
|
||||
auth: true,
|
||||
name: 'ProfileSettingsPage',
|
||||
auth: true,
|
||||
authPage: 'LoginPage',
|
||||
component: props => <ProfileSettingsPage {...props} />,
|
||||
},
|
||||
{
|
||||
|
|
@ -161,89 +162,85 @@ const routeConfiguration = () => {
|
|||
},
|
||||
{
|
||||
path: '/inbox',
|
||||
auth: true,
|
||||
name: 'InboxBasePage',
|
||||
auth: true,
|
||||
authPage: 'LoginPage',
|
||||
component: () => <NamedRedirect name="InboxPage" params={{ tab: 'sales' }} />,
|
||||
},
|
||||
{
|
||||
path: '/inbox/:tab',
|
||||
auth: true,
|
||||
name: 'InboxPage',
|
||||
auth: true,
|
||||
authPage: 'LoginPage',
|
||||
component: props => <InboxPage {...props} />,
|
||||
loadData: InboxPage.loadData,
|
||||
},
|
||||
{
|
||||
path: '/order/:id',
|
||||
auth: true,
|
||||
name: 'OrderPage',
|
||||
component: RedirectToLandingPage,
|
||||
auth: true,
|
||||
authPage: 'LoginPage',
|
||||
component: props => <NamedRedirect name="OrderDetailsPage" params={{ ...props.params }} />,
|
||||
},
|
||||
{
|
||||
path: '/order/:id/details',
|
||||
auth: true,
|
||||
name: 'OrderDetailsPage',
|
||||
auth: true,
|
||||
authPage: 'LoginPage',
|
||||
component: props => <OrderPage {...props} tab="details" />,
|
||||
loadData: OrderPage.loadData,
|
||||
setInitialValues: OrderPage.setInitialValues,
|
||||
},
|
||||
{
|
||||
path: '/order/:id/discussion',
|
||||
auth: true,
|
||||
name: 'OrderDiscussionPage',
|
||||
component: props => <OrderPage {...props} tab="discussion" />,
|
||||
loadData: OrderPage.loadData,
|
||||
setInitialValues: OrderPage.setInitialValues,
|
||||
},
|
||||
{
|
||||
path: '/sale/:id',
|
||||
auth: true,
|
||||
name: 'SalePage',
|
||||
component: props => <SalePage {...props} tab="discussion" />,
|
||||
auth: true,
|
||||
authPage: 'LoginPage',
|
||||
component: props => <NamedRedirect name="SaleDetailsPage" params={{ ...props.params }} />,
|
||||
},
|
||||
{
|
||||
path: '/sale/:id/details',
|
||||
auth: true,
|
||||
name: 'SaleDetailsPage',
|
||||
auth: true,
|
||||
authPage: 'LoginPage',
|
||||
component: props => <SalePage {...props} tab="details" />,
|
||||
loadData: SalePage.loadData,
|
||||
},
|
||||
{
|
||||
path: '/sale/:id/discussion',
|
||||
auth: true,
|
||||
name: 'SaleDiscussionPage',
|
||||
component: props => <SalePage {...props} tab="discussion" />,
|
||||
loadData: SalePage.loadData,
|
||||
},
|
||||
{
|
||||
path: '/listings',
|
||||
auth: true,
|
||||
name: 'ManageListingsPage',
|
||||
auth: true,
|
||||
authPage: 'LoginPage',
|
||||
component: props => <ManageListingsPage {...props} />,
|
||||
loadData: ManageListingsPage.loadData,
|
||||
},
|
||||
{
|
||||
path: '/account',
|
||||
auth: true,
|
||||
name: 'AccountSettingsPage',
|
||||
auth: true,
|
||||
authPage: 'LoginPage',
|
||||
component: () => <NamedRedirect name="ContactDetailsPage" />,
|
||||
},
|
||||
{
|
||||
path: '/account/contact-details',
|
||||
auth: true,
|
||||
name: 'ContactDetailsPage',
|
||||
auth: true,
|
||||
authPage: 'LoginPage',
|
||||
component: props => <ContactDetailsPage {...props} />,
|
||||
loadData: ContactDetailsPage.loadData,
|
||||
},
|
||||
{
|
||||
path: '/account/change-password',
|
||||
auth: true,
|
||||
name: 'PasswordChangePage',
|
||||
auth: true,
|
||||
authPage: 'LoginPage',
|
||||
component: props => <PasswordChangePage {...props} />,
|
||||
},
|
||||
{
|
||||
path: '/account/payout-preferences',
|
||||
auth: true,
|
||||
name: 'PayoutPreferencesPage',
|
||||
auth: true,
|
||||
authPage: 'LoginPage',
|
||||
component: props => <PayoutPreferencesPage {...props} />,
|
||||
},
|
||||
{
|
||||
|
|
@ -301,9 +298,9 @@ const routeConfiguration = () => {
|
|||
// The API expects that the Starter App implements /verify-email endpoint
|
||||
{
|
||||
path: '/verify-email',
|
||||
name: 'EmailVerificationPage',
|
||||
auth: true,
|
||||
authPage: 'LoginPage',
|
||||
name: 'EmailVerificationPage',
|
||||
component: props => <EmailVerificationPage {...props} />,
|
||||
},
|
||||
];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue