Fix settings validation and session errors

This commit is contained in:
gpt-engineer-app[bot]
2025-10-14 23:48:34 +00:00
parent 439a7f4abf
commit 21d16f01ed
5 changed files with 62 additions and 29 deletions

View File

@@ -146,19 +146,30 @@ export function SecurityTab() {
const fetchSessions = async () => {
if (!user) return;
const { data, error } = await supabase.rpc('get_my_sessions');
setLoadingSessions(true);
if (error) {
try {
const { data, error } = await supabase.rpc('get_my_sessions');
if (error) {
throw error;
}
setSessions((data as AuthSession[]) || []);
} catch (error) {
logger.error('Failed to fetch sessions', {
userId: user.id,
action: 'fetch_sessions',
error: error.message
error: error instanceof Error ? error.message : String(error)
});
handleError(error, { action: 'Load sessions', userId: user.id });
} else {
setSessions((data as AuthSession[]) || []);
handleError(error, {
action: 'Load active sessions',
userId: user.id
});
setSessions([]);
} finally {
setLoadingSessions(false);
}
setLoadingSessions(false);
};
const initiateSessionRevoke = async (sessionId: string) => {