mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 09:33:46 +00:00
fix: infinite reload loop on login when Telegram widget unavailable
When the Telegram OIDC widget fails to load (ad blockers, DNS, CSP), the deep link polling fallback caused an infinite page reload: 1. pollDeepLinkToken received 202 (pending) which axios treated as success 2. loginWithDeepLink stored undefined tokens with isAuthenticated=true 3. checkAdminStatus() fired with invalid token → 401 4. Response interceptor called safeRedirectToLogin() → page reload → loop Fixes: - pollDeepLinkToken: validateStatus rejects non-200 (202 now caught in poll loop) - AUTH_ENDPOINTS: add /cabinet/auth/deeplink/ and /cabinet/auth/login/auto - safeRedirectToLogin: guard against redirect when already on /login - loginWithDeepLink: validate response tokens before storing - setTokens: validate tokens in store method (protects AutoLogin, VerifyEmail, etc.)
This commit is contained in:
@@ -258,6 +258,8 @@ export function getAndClearReturnUrl(): string | null {
|
||||
|
||||
export function safeRedirectToLogin(): void {
|
||||
if (typeof window !== 'undefined') {
|
||||
// Guard: don't redirect if already on /login to prevent infinite reload loops
|
||||
if (window.location.pathname === '/login') return;
|
||||
saveReturnUrl();
|
||||
window.location.href = '/login';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user