From 57c88bf040d87f9b55a9dd79c098e50b357bf8f4 Mon Sep 17 00:00:00 2001 From: ezwelty Date: Tue, 27 Dec 2022 10:01:30 +0100 Subject: [PATCH] Use auth paths that match existing website - /account -> /users/edit - /login -> /users/sign_in - /signup -> /users/sign_up - /password -> /users/password - /password/reset -> /users/password/new - /password/set -> /users/password/edit (API update required) - /confirmation/new -> /users/confirmation/new - /confirmation -> /users/confirmation (API update required) See #246. --- src/components/auth/AccountPage.js | 2 +- src/components/auth/ConfirmationPage.js | 6 +++--- src/components/auth/ConfirmationResendPage.js | 10 ++++++---- src/components/auth/LoginPage.js | 8 +++++--- src/components/auth/PasswordResetPage.js | 10 ++++++---- src/components/auth/PasswordSetPage.js | 14 ++++++++------ src/components/auth/SignupPage.js | 2 +- src/components/auth/authRoutes.js | 14 +++++++------- src/components/desktop/Header.js | 8 ++++---- src/components/mobile/MobileLayout.js | 4 ++-- src/components/mobile/TopBarSwitch.js | 10 +++++----- src/components/settings/SettingsPage.js | 11 ++++++++--- 12 files changed, 56 insertions(+), 43 deletions(-) diff --git a/src/components/auth/AccountPage.js b/src/components/auth/AccountPage.js index 65a1dab8..ed899c63 100644 --- a/src/components/auth/AccountPage.js +++ b/src/components/auth/AccountPage.js @@ -55,7 +55,7 @@ const AccountPage = () => { }, []) if (!isLoading && !isLoggedIn) { - return + return } const handleSubmit = async (values) => { diff --git a/src/components/auth/ConfirmationPage.js b/src/components/auth/ConfirmationPage.js index e4638484..4b25a17e 100644 --- a/src/components/auth/ConfirmationPage.js +++ b/src/components/auth/ConfirmationPage.js @@ -13,15 +13,15 @@ const ConfirmationPage = () => { if (!token) { toast.error("Confirmation token can't be blank", { autoClose: 5000 }) - history.push('/confirmation/new') + history.push('/users/confirmation/new') } else { try { const { email } = await confirmUser(token) toast.success('Your email has been confirmed.') - history.push({ pathname: '/login', state: { email } }) + history.push({ pathname: '/users/sign_in', state: { email } }) } catch (e) { toast.error(e.response?.data.error, { autoClose: 5000 }) - history.push('/confirmation/new') + history.push('/users/confirmation/new') } } } diff --git a/src/components/auth/ConfirmationResendPage.js b/src/components/auth/ConfirmationResendPage.js index 857218d0..87ae84b2 100644 --- a/src/components/auth/ConfirmationResendPage.js +++ b/src/components/auth/ConfirmationResendPage.js @@ -27,7 +27,7 @@ const ConfirmationResendPage = () => { 'You will receive an email with instructions for how to confirm your email address in a few minutes', { autoClose: 5000 }, ) - history.push('/login') + history.push('/users/sign_in') } catch (e) { toast.error(e.response?.data.error) console.error(e.response) @@ -40,9 +40,11 @@ const ConfirmationResendPage = () => {

Resend confirmation instructions

- Login - Sign up - Resend confirmation instructions + Login + Sign up + + Resend confirmation instructions + ) diff --git a/src/components/auth/LoginPage.js b/src/components/auth/LoginPage.js index d9e7913c..f5643c65 100644 --- a/src/components/auth/LoginPage.js +++ b/src/components/auth/LoginPage.js @@ -75,9 +75,11 @@ const LoginPage = () => { )} - Sign up - Reset your password - Resend confirmation instructions + Sign up + Reset your password + + Resend confirmation instructions + diff --git a/src/components/auth/PasswordResetPage.js b/src/components/auth/PasswordResetPage.js index bb1642a6..e414534b 100644 --- a/src/components/auth/PasswordResetPage.js +++ b/src/components/auth/PasswordResetPage.js @@ -27,7 +27,7 @@ const PasswordResetPage = () => { 'You will receive an email with instructions on how to reset your password in a few minutes', { autoClose: 5000 }, ) - history.push('/login') + history.push('/users/sign_in') } catch (e) { toast.error('Email not found') console.error(e.response) @@ -40,9 +40,11 @@ const PasswordResetPage = () => {

Send password reset instructions

- Login - Sign up - Resend confirmation instructions + Login + Sign up + + Resend confirmation instructions + ) diff --git a/src/components/auth/PasswordSetPage.js b/src/components/auth/PasswordSetPage.js index 54aa6c24..5fff2067 100644 --- a/src/components/auth/PasswordSetPage.js +++ b/src/components/auth/PasswordSetPage.js @@ -27,7 +27,7 @@ const PasswordSetPage = () => { "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided.", { autoClose: 5000 }, ) - history.push('/login') + history.push('/users/sign_in') } }, [history]) @@ -44,11 +44,11 @@ const PasswordSetPage = () => { toast.success('Your password has been changed successfully.', { autoClose: 5000, }) - history.push({ pathname: '/login', state: { email } }) + history.push({ pathname: '/users/sign_in', state: { email } }) } catch (e) { toast.error('Invalid password reset link') console.error(e.response) - history.push('/login') + history.push('/users/sign_in') } } @@ -91,9 +91,11 @@ const PasswordSetPage = () => { )} - Login - Sign up - Resend confirmation instructions + Login + Sign up + + Resend confirmation instructions + ) diff --git a/src/components/auth/SignupPage.js b/src/components/auth/SignupPage.js index 4789921d..d94e5570 100644 --- a/src/components/auth/SignupPage.js +++ b/src/components/auth/SignupPage.js @@ -53,7 +53,7 @@ const SignupPage = () => {

Sign up

- Have an account? Login + Have an account? Login { matchPath(useLocation().pathname, { path: aboutRoutes.map((route) => route.props.path).flat(), }) !== null - const isAccountPage = useRouteMatch('/account') !== null + const isAccountPage = useRouteMatch('/users/edit') !== null return ( @@ -232,7 +232,7 @@ const Header = () => { } isMatch={isAccountPage} > - + {t('My Account')} Logout @@ -241,12 +241,12 @@ const Header = () => { ) : ( <>
  • - + {t('Login')}
  • - + {t('Sign up')}
  • diff --git a/src/components/mobile/MobileLayout.js b/src/components/mobile/MobileLayout.js index 9ee91004..4139bd2b 100644 --- a/src/components/mobile/MobileLayout.js +++ b/src/components/mobile/MobileLayout.js @@ -41,7 +41,7 @@ const MobileLayout = () => { )) if ( - ['/list', '/settings', '/account'].some((path) => + ['/list', '/settings', '/users/edit'].some((path) => matchPath(pathname, { path, exact: false, strict: false }), ) ) { @@ -96,7 +96,7 @@ const MobileLayout = () => { - + diff --git a/src/components/mobile/TopBarSwitch.js b/src/components/mobile/TopBarSwitch.js index 5562eba0..98313e1d 100644 --- a/src/components/mobile/TopBarSwitch.js +++ b/src/components/mobile/TopBarSwitch.js @@ -13,12 +13,12 @@ const TopBarSwitch = () => { { {user ? ( <>

    Logged in as {user.name || user.email}

    - ) : ( <> - - +