mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-22 17:11:23 -05:00
Refactor: Implement AAL2 enforcement fix
This commit is contained in:
@@ -44,7 +44,7 @@ export interface AdminGuardState {
|
||||
export function useAdminGuard(requireMFA: boolean = true): AdminGuardState {
|
||||
const { user, loading: authLoading } = useAuth();
|
||||
const { isModerator, loading: roleLoading } = useUserRole();
|
||||
const { needsEnrollment, loading: mfaLoading } = useRequireMFA();
|
||||
const { needsEnrollment, needsVerification, loading: mfaLoading } = useRequireMFA();
|
||||
const navigate = useNavigate();
|
||||
|
||||
// Auto-redirect based on auth state
|
||||
@@ -60,7 +60,8 @@ export function useAdminGuard(requireMFA: boolean = true): AdminGuardState {
|
||||
|
||||
const isLoading = authLoading || roleLoading || mfaLoading;
|
||||
const isAuthorized = !!user && isModerator();
|
||||
const needsMFA = requireMFA && needsEnrollment;
|
||||
// Block access if EITHER not enrolled OR session is at AAL1 (needs verification)
|
||||
const needsMFA = requireMFA && (needsEnrollment || needsVerification);
|
||||
|
||||
return {
|
||||
isLoading,
|
||||
|
||||
Reference in New Issue
Block a user