feat: Add force logout endpoint

This commit is contained in:
gpt-engineer-app[bot]
2025-10-11 16:46:10 +00:00
parent 595ab97916
commit 7a3ad6b000
3 changed files with 88 additions and 0 deletions

View File

@@ -156,6 +156,37 @@ class AuthStorage {
: null
};
}
// Clear all auth-related storage (for force logout)
clearAll(): void {
console.log('[AuthStorage] Clearing all auth storage');
try {
if (this.storage) {
// Get all keys from storage
const keys: string[] = [];
for (let i = 0; i < this.storage.length; i++) {
const key = this.storage.key(i);
if (key?.startsWith('sb-')) {
keys.push(key);
}
}
// Remove all Supabase auth keys
keys.forEach(key => {
console.log('[AuthStorage] Removing key:', key);
this.storage!.removeItem(key);
});
}
// Clear memory storage
this.memoryStorage.clear();
console.log('[AuthStorage] ✓ All auth storage cleared');
} catch (error) {
console.error('[AuthStorage] Error clearing storage:', error);
// Still clear memory storage as fallback
this.memoryStorage.clear();
}
}
}
export const authStorage = new AuthStorage();