mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 15:11:12 -05:00
feat: Improve MFA check reliability
This commit is contained in:
@@ -19,17 +19,29 @@ import { setStepUpRequired, setAuthMethod, clearAllAuthFlags } from './sessionFl
|
||||
* Always returns ground truth from server, not cached session data
|
||||
*/
|
||||
export async function getSessionAal(session: Session | null): Promise<AALLevel> {
|
||||
if (!session) return 'aal1';
|
||||
if (!session) {
|
||||
console.log('🔍 [AuthService] No session, returning aal1');
|
||||
return 'aal1';
|
||||
}
|
||||
|
||||
try {
|
||||
const { data, error } = await supabase.auth.mfa.getAuthenticatorAssuranceLevel();
|
||||
|
||||
console.log('🔍 [AuthService] getSessionAal result:', {
|
||||
hasData: !!data,
|
||||
currentLevel: data?.currentLevel,
|
||||
nextLevel: data?.nextLevel,
|
||||
error: error?.message
|
||||
});
|
||||
|
||||
if (error) {
|
||||
console.error('[AuthService] Error getting AAL:', error);
|
||||
return 'aal1';
|
||||
}
|
||||
|
||||
return (data.currentLevel as AALLevel) || 'aal1';
|
||||
const level = (data.currentLevel as AALLevel) || 'aal1';
|
||||
console.log('🔐 [AuthService] Returning AAL:', level);
|
||||
return level;
|
||||
} catch (error) {
|
||||
console.error('[AuthService] Exception getting AAL:', error);
|
||||
return 'aal1';
|
||||
|
||||
Reference in New Issue
Block a user