diff --git a/apps/user/utils/common.ts b/apps/user/utils/common.ts index afb7d1a..c68e11b 100644 --- a/apps/user/utils/common.ts +++ b/apps/user/utils/common.ts @@ -38,15 +38,21 @@ export function setRedirectUrl(value?: string) { } export function getRedirectUrl() { - return sessionStorage.getItem('redirect-url') ?? '/dashboard'; + let url = sessionStorage.getItem('redirect-url') ?? '/dashboard'; + if (url.startsWith('/oauth/') || url.startsWith('/auth')) { + url = '/dashboard'; + } + if (url) { + sessionStorage.removeItem('redirect-url'); + return url; + } } export function Logout() { if (!isBrowser()) return; cookies.remove('Authorization'); const pathname = location.pathname; - console.log(pathname); - if (!['', '/', '/auth', '/tos'].includes(pathname) || !pathname.includes('/oauth/')) { + if (!['', '/', '/auth', '/tos'].includes(pathname) && !pathname.startsWith('/oauth/')) { setRedirectUrl(location.pathname); location.href = `/auth`; }