diff --git a/src/components/Authenticator/authenticator.ts b/src/components/Authenticator/authenticator.ts index 183e3dc9f..91cf60bf4 100644 --- a/src/components/Authenticator/authenticator.ts +++ b/src/components/Authenticator/authenticator.ts @@ -29,20 +29,33 @@ function showHideGuestElements(hideOrShow: 'hide' | 'show' = 'hide') { }); } -/** - * Prepares the UI for the user who is logged in - */ +// Prepares the UI for the user who is logged in function handleGuest() { + const authenticatedRoutes = [ + '/settings/profile', + '/settings/change-password', + ]; + showHideAuthElements('hide'); showHideGuestElements('show'); + + // If the user is on an authenticated route, redirect them to the home page + if (authenticatedRoutes.includes(window.location.pathname)) { + window.location.href = '/'; + } } -/** - * Prepares the UI for the user who is logged out - */ +// Prepares the UI for the user who is logged out function handleAuthenticated() { + const guestRoutes = ['/login', '/signup']; + showHideGuestElements('hide'); showHideAuthElements('show'); + + // If the user is on a guest route, redirect them to the home page + if (guestRoutes.includes(window.location.pathname)) { + window.location.href = '/'; + } } export function handleAuthRequired() { diff --git a/src/components/Navigation/navigation.ts b/src/components/Navigation/navigation.ts index ceab0a675..82aaf9233 100644 --- a/src/components/Navigation/navigation.ts +++ b/src/components/Navigation/navigation.ts @@ -4,7 +4,7 @@ import { handleAuthRequired } from '../Authenticator/authenticator'; function logout() { Cookies.remove(TOKEN_COOKIE_NAME); - handleAuthRequired(); + // Reloading will automatically redirect the user if required window.location.reload(); } diff --git a/src/pages/signup.astro b/src/pages/signup.astro index 1db5e3717..7cd9bb4cf 100644 --- a/src/pages/signup.astro +++ b/src/pages/signup.astro @@ -15,16 +15,17 @@ import { GoogleButton } from '../components/AuthenticationFlow/GoogleButton'; >
- Create an account to track your progress, showcase your skill-set and be a part of the community. - videos. +
+ Create an account to track your progress, showcase your skill-set and + be a part of the community. videos.