ui frotneedn fixes

This commit is contained in:
IGNY8 VPS (Salman)
2025-11-26 06:47:23 +00:00
parent 451594bd29
commit 4fe68cc271
40 changed files with 1638 additions and 275 deletions

View File

@@ -235,12 +235,11 @@ export const useAuthStore = create<AuthState>()(
set({ user: refreshedUser, isAuthenticated: true });
} catch (error: any) {
// Only logout on authentication/authorization errors, not on network errors
// Network errors (500, timeout, etc.) should not log the user out
// Only logout on specific authentication/authorization errors
// Do NOT logout on 401/403 - fetchAPI handles token refresh automatically
// A 401 that reaches here means refresh token is invalid, which fetchAPI handles by logging out
const isAuthError = error?.code === 'ACCOUNT_REQUIRED' ||
error?.code === 'PLAN_REQUIRED' ||
error?.status === 401 ||
error?.status === 403 ||
(error?.message && error.message.includes('Not authenticated'));
if (isAuthError) {
@@ -248,7 +247,7 @@ export const useAuthStore = create<AuthState>()(
console.warn('Authentication error during refresh, logging out:', error);
set({ user: null, token: null, refreshToken: null, isAuthenticated: false });
} else {
// Network/server error - don't logout, just throw the error
// Network/server error or 401/403 (handled by fetchAPI) - don't logout
// The caller (AppLayout) will handle it gracefully
console.debug('Non-auth error during refresh (will retry):', error);
}