From 795476209a77d6c1fc97835720e45a584281f1b8 Mon Sep 17 00:00:00 2001 From: "web@ppanel" Date: Wed, 22 Jan 2025 22:41:17 +0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(redirect):=20Update=20redire?= =?UTF-8?q?ct=20URL=20logic=20to=20ensure=20proper=20handling=20of=20OAuth?= =?UTF-8?q?=20and=20auth=20paths?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/user/utils/common.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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`; }