mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 18:51:11 -05:00
feat: Improve MFA check reliability
This commit is contained in:
@@ -93,6 +93,17 @@ export function useModerationQueueManager(config: ModerationQueueManagerConfig):
|
||||
const queryClient = useQueryClient();
|
||||
const { aal } = useAuth();
|
||||
|
||||
// Debug AAL status
|
||||
useEffect(() => {
|
||||
logger.log('🔐 [QUEUE MANAGER] AAL Status:', {
|
||||
aal,
|
||||
isNull: aal === null,
|
||||
isAal1: aal === 'aal1',
|
||||
isAal2: aal === 'aal2',
|
||||
timestamp: new Date().toISOString()
|
||||
});
|
||||
}, [aal]);
|
||||
|
||||
// Initialize sub-hooks
|
||||
const filters = useModerationFilters({
|
||||
initialEntityFilter: "all",
|
||||
@@ -273,7 +284,30 @@ export function useModerationQueueManager(config: ModerationQueueManagerConfig):
|
||||
setActionLoading(item.id);
|
||||
|
||||
// Check MFA (AAL2) requirement before moderation action
|
||||
if (aal === null) {
|
||||
logger.log('⏳ [QUEUE MANAGER] AAL is null, waiting for authentication status...');
|
||||
toast({
|
||||
title: "Loading Authentication Status",
|
||||
description: "Please wait while we verify your authentication level...",
|
||||
});
|
||||
setActionLoading(null);
|
||||
|
||||
// Retry after 1 second
|
||||
setTimeout(() => {
|
||||
logger.log('🔄 [QUEUE MANAGER] Retrying action after AAL load');
|
||||
performAction(item, action, moderatorNotes);
|
||||
}, 1000);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (aal !== 'aal2') {
|
||||
logger.warn('🚫 [QUEUE MANAGER] MFA check failed', {
|
||||
aal,
|
||||
expected: 'aal2',
|
||||
userId: user?.id
|
||||
});
|
||||
|
||||
toast({
|
||||
title: "MFA Verification Required",
|
||||
description: "You must complete multi-factor authentication to perform moderation actions.",
|
||||
@@ -283,6 +317,8 @@ export function useModerationQueueManager(config: ModerationQueueManagerConfig):
|
||||
return;
|
||||
}
|
||||
|
||||
logger.log('✅ [QUEUE MANAGER] MFA check passed', { aal });
|
||||
|
||||
// Calculate stat delta for optimistic update
|
||||
const statDelta: Partial<ModerationStats> = {};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user