From 214525b1403128765fcbfec6de098403c4e40eda Mon Sep 17 00:00:00 2001 From: Kimmo Puputti Date: Fri, 1 Dec 2017 16:09:09 +0200 Subject: [PATCH] Make auth routing more intuitive - Use Login as auth page for URLs where user edits their own data or where we link from elsewhere - Order route keys consistently - Redirect /order/:id to /order/:id/details - Redirect /sale/:id to /sale/:id/details - Remove /order/:id/discussion and /sale/:id/discussion routes --- src/app.test.js | 35 ++++++++++------------ src/routeConfiguration.js | 63 +++++++++++++++++++-------------------- 2 files changed, 46 insertions(+), 52 deletions(-) diff --git a/src/app.test.js b/src/app.test.js index 728d5ca8..27b0ff69 100644 --- a/src/app.test.js +++ b/src/app.test.js @@ -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) => { diff --git a/src/routeConfiguration.js b/src/routeConfiguration.js index b8aced52..c94f42ab 100644 --- a/src/routeConfiguration.js +++ b/src/routeConfiguration.js @@ -95,15 +95,15 @@ const routeConfiguration = () => { }, { path: '/l/:slug/:id/checkout', - auth: true, name: 'CheckoutPage', + auth: true, component: props => , setInitialValues: CheckoutPage.setInitialValues, }, { - auth: true, path: '/l/new', name: 'NewListingPage', + auth: true, component: () => ( { ), }, { - auth: true, path: '/l/:slug/:id/:type/:tab', name: 'EditListingPage', + auth: true, component: props => , loadData: EditListingPage.loadData, }, @@ -140,8 +140,9 @@ const routeConfiguration = () => { }, { path: '/profile-settings', - auth: true, name: 'ProfileSettingsPage', + auth: true, + authPage: 'LoginPage', component: props => , }, { @@ -161,89 +162,85 @@ const routeConfiguration = () => { }, { path: '/inbox', - auth: true, name: 'InboxBasePage', + auth: true, + authPage: 'LoginPage', component: () => , }, { path: '/inbox/:tab', - auth: true, name: 'InboxPage', + auth: true, + authPage: 'LoginPage', component: props => , loadData: InboxPage.loadData, }, { path: '/order/:id', - auth: true, name: 'OrderPage', - component: RedirectToLandingPage, + auth: true, + authPage: 'LoginPage', + component: props => , }, { path: '/order/:id/details', - auth: true, name: 'OrderDetailsPage', + auth: true, + authPage: 'LoginPage', component: props => , loadData: OrderPage.loadData, setInitialValues: OrderPage.setInitialValues, }, - { - path: '/order/:id/discussion', - auth: true, - name: 'OrderDiscussionPage', - component: props => , - loadData: OrderPage.loadData, - setInitialValues: OrderPage.setInitialValues, - }, { path: '/sale/:id', - auth: true, name: 'SalePage', - component: props => , + auth: true, + authPage: 'LoginPage', + component: props => , }, { path: '/sale/:id/details', - auth: true, name: 'SaleDetailsPage', + auth: true, + authPage: 'LoginPage', component: props => , loadData: SalePage.loadData, }, - { - path: '/sale/:id/discussion', - auth: true, - name: 'SaleDiscussionPage', - component: props => , - loadData: SalePage.loadData, - }, { path: '/listings', - auth: true, name: 'ManageListingsPage', + auth: true, + authPage: 'LoginPage', component: props => , loadData: ManageListingsPage.loadData, }, { path: '/account', - auth: true, name: 'AccountSettingsPage', + auth: true, + authPage: 'LoginPage', component: () => , }, { path: '/account/contact-details', - auth: true, name: 'ContactDetailsPage', + auth: true, + authPage: 'LoginPage', component: props => , loadData: ContactDetailsPage.loadData, }, { path: '/account/change-password', - auth: true, name: 'PasswordChangePage', + auth: true, + authPage: 'LoginPage', component: props => , }, { path: '/account/payout-preferences', - auth: true, name: 'PayoutPreferencesPage', + auth: true, + authPage: 'LoginPage', component: 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 => , }, ];