mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-30 02:23:47 +00:00
fix: clear all cached auth state on Telegram MiniApp retry
When users hit 'Try Again' after auth failure, clear ALL cached state (tokens, SDK launch params, initData, zustand persist, tg_user_id) to prevent stale token loops. Applies to both Login and TelegramRedirect retry handlers.
This commit is contained in:
@@ -6,6 +6,7 @@ import { useAuthStore } from '../store/auth';
|
||||
import { useShallow } from 'zustand/shallow';
|
||||
import { brandingApi } from '../api/branding';
|
||||
import { isInTelegramWebApp, getTelegramInitData } from '../hooks/useTelegramSDK';
|
||||
import { tokenStorage } from '../utils/token';
|
||||
|
||||
// Validate redirect URL to prevent open redirect attacks
|
||||
const getSafeRedirectUrl = (url: string | null): string => {
|
||||
@@ -117,6 +118,14 @@ export default function TelegramRedirect() {
|
||||
const newCount = retryCount + 1;
|
||||
setRetryCount(newCount);
|
||||
sessionStorage.setItem(RETRY_COUNT_KEY, String(newCount));
|
||||
|
||||
// Clear all cached auth state to prevent stale token/initData loops
|
||||
tokenStorage.clearTokens();
|
||||
sessionStorage.removeItem('tapps/launchParams');
|
||||
sessionStorage.removeItem('telegram_init_data');
|
||||
localStorage.removeItem('cabinet-auth');
|
||||
localStorage.removeItem('tg_user_id');
|
||||
|
||||
setStatus('loading');
|
||||
setErrorMessage('');
|
||||
window.location.reload();
|
||||
|
||||
Reference in New Issue
Block a user