🐛 fix(redirect): Update redirect URL logic to ensure proper handling of OAuth and auth paths

This commit is contained in:
web@ppanel 2025-01-22 22:41:17 +07:00
parent 9227411d74
commit 795476209a

View File

@ -38,15 +38,21 @@ export function setRedirectUrl(value?: string) {
} }
export function getRedirectUrl() { 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() { export function Logout() {
if (!isBrowser()) return; if (!isBrowser()) return;
cookies.remove('Authorization'); cookies.remove('Authorization');
const pathname = location.pathname; const pathname = location.pathname;
console.log(pathname); if (!['', '/', '/auth', '/tos'].includes(pathname) && !pathname.startsWith('/oauth/')) {
if (!['', '/', '/auth', '/tos'].includes(pathname) || !pathname.includes('/oauth/')) {
setRedirectUrl(location.pathname); setRedirectUrl(location.pathname);
location.href = `/auth`; location.href = `/auth`;
} }