feat: Improve MFA check reliability

This commit is contained in:
gpt-engineer-app[bot]
2025-10-17 19:06:35 +00:00
parent 47c1a39442
commit 152a90ae9d
3 changed files with 51 additions and 2 deletions

View File

@@ -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> = {};