mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-28 06:47:03 -05:00
Compare commits
2 Commits
c4f975ff12
...
5985ee352d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5985ee352d | ||
|
|
df9f997c64 |
@@ -1,6 +1,6 @@
|
|||||||
import { ReactNode, useCallback } from 'react';
|
import { ReactNode, useCallback } from 'react';
|
||||||
import { AdminLayout } from '@/components/layout/AdminLayout';
|
import { AdminLayout } from '@/components/layout/AdminLayout';
|
||||||
import { MFARequiredAlert } from '@/components/auth/MFARequiredAlert';
|
import { MFAGuard } from '@/components/auth/MFAGuard';
|
||||||
import { QueueSkeleton } from '@/components/moderation/QueueSkeleton';
|
import { QueueSkeleton } from '@/components/moderation/QueueSkeleton';
|
||||||
import { useAdminGuard } from '@/hooks/useAdminGuard';
|
import { useAdminGuard } from '@/hooks/useAdminGuard';
|
||||||
import { useAdminSettings } from '@/hooks/useAdminSettings';
|
import { useAdminSettings } from '@/hooks/useAdminSettings';
|
||||||
@@ -104,15 +104,6 @@ export function AdminPageLayout({
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// MFA required
|
|
||||||
if (needsMFA) {
|
|
||||||
return (
|
|
||||||
<AdminLayout>
|
|
||||||
<MFARequiredAlert />
|
|
||||||
</AdminLayout>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Main content
|
// Main content
|
||||||
return (
|
return (
|
||||||
<AdminLayout
|
<AdminLayout
|
||||||
@@ -121,6 +112,7 @@ export function AdminPageLayout({
|
|||||||
pollInterval={showRefreshControls ? pollInterval : undefined}
|
pollInterval={showRefreshControls ? pollInterval : undefined}
|
||||||
lastUpdated={showRefreshControls ? (lastUpdated as Date) : undefined}
|
lastUpdated={showRefreshControls ? (lastUpdated as Date) : undefined}
|
||||||
>
|
>
|
||||||
|
<MFAGuard>
|
||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
<div>
|
<div>
|
||||||
<h1 className="text-2xl font-bold tracking-tight">{title}</h1>
|
<h1 className="text-2xl font-bold tracking-tight">{title}</h1>
|
||||||
@@ -128,6 +120,7 @@ export function AdminPageLayout({
|
|||||||
</div>
|
</div>
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
|
</MFAGuard>
|
||||||
</AdminLayout>
|
</AdminLayout>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
110
src/components/auth/AutoMFAVerificationModal.tsx
Normal file
110
src/components/auth/AutoMFAVerificationModal.tsx
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
import { useState, useEffect } from 'react';
|
||||||
|
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '@/components/ui/dialog';
|
||||||
|
import { MFAChallenge } from './MFAChallenge';
|
||||||
|
import { Shield, AlertCircle, Loader2 } from 'lucide-react';
|
||||||
|
import { getEnrolledFactors } from '@/lib/authService';
|
||||||
|
import { useAuth } from '@/hooks/useAuth';
|
||||||
|
import { handleError } from '@/lib/errorHandler';
|
||||||
|
|
||||||
|
interface AutoMFAVerificationModalProps {
|
||||||
|
open: boolean;
|
||||||
|
onSuccess: () => void;
|
||||||
|
onCancel: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function AutoMFAVerificationModal({
|
||||||
|
open,
|
||||||
|
onSuccess,
|
||||||
|
onCancel
|
||||||
|
}: AutoMFAVerificationModalProps) {
|
||||||
|
const { session } = useAuth();
|
||||||
|
const [factorId, setFactorId] = useState<string | null>(null);
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
// Fetch enrolled factor automatically when modal opens
|
||||||
|
useEffect(() => {
|
||||||
|
if (!open || !session) return;
|
||||||
|
|
||||||
|
const fetchFactor = async () => {
|
||||||
|
setLoading(true);
|
||||||
|
setError(null);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const factors = await getEnrolledFactors();
|
||||||
|
|
||||||
|
if (factors.length === 0) {
|
||||||
|
setError('No MFA method enrolled. Please set up MFA in settings.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use the first verified TOTP factor
|
||||||
|
const totpFactor = factors.find(f => f.factor_type === 'totp');
|
||||||
|
if (totpFactor) {
|
||||||
|
setFactorId(totpFactor.id);
|
||||||
|
} else {
|
||||||
|
setError('No valid MFA method found. Please check your security settings.');
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
setError('Failed to load MFA settings. Please try again.');
|
||||||
|
handleError(err, {
|
||||||
|
action: 'Fetch MFA Factors for Auto-Verification',
|
||||||
|
metadata: { context: 'AutoMFAVerificationModal' }
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
fetchFactor();
|
||||||
|
}, [open, session]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Dialog
|
||||||
|
open={open}
|
||||||
|
onOpenChange={(isOpen) => {
|
||||||
|
if (!isOpen) {
|
||||||
|
onCancel();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<DialogContent
|
||||||
|
className="sm:max-w-md"
|
||||||
|
onInteractOutside={(e) => e.preventDefault()}
|
||||||
|
onEscapeKeyDown={(e) => e.preventDefault()}
|
||||||
|
>
|
||||||
|
<DialogHeader>
|
||||||
|
<div className="flex items-center gap-2 justify-center mb-2">
|
||||||
|
<Shield className="h-6 w-6 text-primary" />
|
||||||
|
<DialogTitle>Verification Required</DialogTitle>
|
||||||
|
</div>
|
||||||
|
<DialogDescription className="text-center">
|
||||||
|
Your session requires Multi-Factor Authentication to access this area.
|
||||||
|
</DialogDescription>
|
||||||
|
</DialogHeader>
|
||||||
|
|
||||||
|
{loading && (
|
||||||
|
<div className="flex flex-col items-center justify-center py-8 space-y-3">
|
||||||
|
<Loader2 className="h-8 w-8 animate-spin text-primary" />
|
||||||
|
<p className="text-sm text-muted-foreground">Loading verification...</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{error && (
|
||||||
|
<div className="flex flex-col items-center justify-center py-6 space-y-3">
|
||||||
|
<AlertCircle className="h-8 w-8 text-destructive" />
|
||||||
|
<p className="text-sm text-center text-muted-foreground">{error}</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{!loading && !error && factorId && (
|
||||||
|
<MFAChallenge
|
||||||
|
factorId={factorId}
|
||||||
|
onSuccess={onSuccess}
|
||||||
|
onCancel={onCancel}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { supabase } from "@/lib/supabaseClient";
|
import { supabase } from "@/lib/supabaseClient";
|
||||||
import { useToast } from "@/hooks/use-toast";
|
import { useToast } from "@/hooks/use-toast";
|
||||||
import { getErrorMessage } from "@/lib/errorHandler";
|
import { handleError } from "@/lib/errorHandler";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from "@/components/ui/label";
|
||||||
import { InputOTP, InputOTPGroup, InputOTPSlot } from "@/components/ui/input-otp";
|
import { InputOTP, InputOTPGroup, InputOTPSlot } from "@/components/ui/input-otp";
|
||||||
@@ -45,10 +45,13 @@ export function MFAChallenge({ factorId, onSuccess, onCancel }: MFAChallengeProp
|
|||||||
onSuccess();
|
onSuccess();
|
||||||
}
|
}
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
toast({
|
handleError(error, {
|
||||||
variant: "destructive",
|
action: 'MFA Verification',
|
||||||
title: "Verification Failed",
|
metadata: {
|
||||||
description: getErrorMessage(error) || "Invalid code. Please try again.",
|
factorId,
|
||||||
|
codeLength: code.length,
|
||||||
|
context: 'MFAChallenge'
|
||||||
|
}
|
||||||
});
|
});
|
||||||
setCode("");
|
setCode("");
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
26
src/components/auth/MFAEnrollmentRequired.tsx
Normal file
26
src/components/auth/MFAEnrollmentRequired.tsx
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
import { Shield } from 'lucide-react';
|
||||||
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
|
export function MFAEnrollmentRequired() {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Alert variant="destructive" className="my-4">
|
||||||
|
<Shield className="h-4 w-4" />
|
||||||
|
<AlertTitle>Multi-Factor Authentication Setup Required</AlertTitle>
|
||||||
|
<AlertDescription className="mt-2 space-y-3">
|
||||||
|
<p>
|
||||||
|
Your role requires Multi-Factor Authentication. Please set up MFA to access this area.
|
||||||
|
</p>
|
||||||
|
<Button
|
||||||
|
onClick={() => navigate('/settings?tab=security')}
|
||||||
|
size="sm"
|
||||||
|
>
|
||||||
|
Set up Multi-Factor Authentication
|
||||||
|
</Button>
|
||||||
|
</AlertDescription>
|
||||||
|
</Alert>
|
||||||
|
);
|
||||||
|
}
|
||||||
74
src/components/auth/MFAGuard.tsx
Normal file
74
src/components/auth/MFAGuard.tsx
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
import { useRequireMFA } from '@/hooks/useRequireMFA';
|
||||||
|
import { AutoMFAVerificationModal } from './AutoMFAVerificationModal';
|
||||||
|
import { MFAEnrollmentRequired } from './MFAEnrollmentRequired';
|
||||||
|
import { useAuth } from '@/hooks/useAuth';
|
||||||
|
import { useToast } from '@/hooks/use-toast';
|
||||||
|
import { handleError } from '@/lib/errorHandler';
|
||||||
|
|
||||||
|
interface MFAGuardProps {
|
||||||
|
children: React.ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smart MFA guard that automatically shows verification modal or enrollment alert
|
||||||
|
*
|
||||||
|
* Usage:
|
||||||
|
* ```tsx
|
||||||
|
* <MFAGuard>
|
||||||
|
* <YourProtectedContent />
|
||||||
|
* </MFAGuard>
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
export function MFAGuard({ children }: MFAGuardProps) {
|
||||||
|
const { needsEnrollment, needsVerification, loading } = useRequireMFA();
|
||||||
|
const { verifySession } = useAuth();
|
||||||
|
const { toast } = useToast();
|
||||||
|
|
||||||
|
const handleVerificationSuccess = async () => {
|
||||||
|
try {
|
||||||
|
// Refresh the session to get updated AAL level
|
||||||
|
await verifySession();
|
||||||
|
|
||||||
|
toast({
|
||||||
|
title: 'Verification Successful',
|
||||||
|
description: 'You can now access this area.',
|
||||||
|
});
|
||||||
|
} catch (error: unknown) {
|
||||||
|
handleError(error, {
|
||||||
|
action: 'MFA Session Verification',
|
||||||
|
metadata: { context: 'MFAGuard' }
|
||||||
|
});
|
||||||
|
// Still attempt to show content - session might be valid despite refresh error
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleVerificationCancel = () => {
|
||||||
|
// Redirect back to main dashboard
|
||||||
|
window.location.href = '/';
|
||||||
|
};
|
||||||
|
|
||||||
|
// Show verification modal automatically when needed
|
||||||
|
if (needsVerification) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<AutoMFAVerificationModal
|
||||||
|
open={true}
|
||||||
|
onSuccess={handleVerificationSuccess}
|
||||||
|
onCancel={handleVerificationCancel}
|
||||||
|
/>
|
||||||
|
{/* Show blurred content behind modal */}
|
||||||
|
<div className="pointer-events-none opacity-50 blur-sm">
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show enrollment alert when user hasn't set up MFA
|
||||||
|
if (needsEnrollment) {
|
||||||
|
return <MFAEnrollmentRequired />;
|
||||||
|
}
|
||||||
|
|
||||||
|
// User has MFA and is verified - show content
|
||||||
|
return <>{children}</>;
|
||||||
|
}
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';
|
|
||||||
import { Button } from '@/components/ui/button';
|
|
||||||
import { Shield } from 'lucide-react';
|
|
||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
import { useAuth } from '@/hooks/useAuth';
|
|
||||||
import { useEffect, useState } from 'react';
|
|
||||||
|
|
||||||
export function MFARequiredAlert() {
|
|
||||||
const navigate = useNavigate();
|
|
||||||
const { checkAalStepUp } = useAuth();
|
|
||||||
const [needsVerification, setNeedsVerification] = useState(false);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
checkAalStepUp().then(result => {
|
|
||||||
setNeedsVerification(result.needsStepUp);
|
|
||||||
});
|
|
||||||
}, [checkAalStepUp]);
|
|
||||||
|
|
||||||
const handleAction = () => {
|
|
||||||
if (needsVerification) {
|
|
||||||
// User has MFA enrolled but needs to verify
|
|
||||||
sessionStorage.setItem('mfa_step_up_required', 'true');
|
|
||||||
navigate('/auth/mfa-step-up');
|
|
||||||
} else {
|
|
||||||
// User needs to enroll in MFA
|
|
||||||
navigate('/settings?tab=security');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Alert variant="destructive" className="my-4">
|
|
||||||
<Shield className="h-4 w-4" />
|
|
||||||
<AlertTitle>Multi-Factor Authentication Required</AlertTitle>
|
|
||||||
<AlertDescription className="mt-2 space-y-3">
|
|
||||||
<p>
|
|
||||||
{needsVerification
|
|
||||||
? 'Please verify your identity with Multi-Factor Authentication to access this area.'
|
|
||||||
: 'Your role requires Multi-Factor Authentication to access this area.'}
|
|
||||||
</p>
|
|
||||||
<Button
|
|
||||||
onClick={handleAction}
|
|
||||||
size="sm"
|
|
||||||
>
|
|
||||||
{needsVerification ? 'Verify Now' : 'Set up Multi-Factor Authentication'}
|
|
||||||
</Button>
|
|
||||||
</AlertDescription>
|
|
||||||
</Alert>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -2,7 +2,7 @@ import { useState, useEffect, useCallback, useRef } from 'react';
|
|||||||
import { supabase } from '@/lib/supabaseClient';
|
import { supabase } from '@/lib/supabaseClient';
|
||||||
import { useAuth } from './useAuth';
|
import { useAuth } from './useAuth';
|
||||||
import { useToast } from './use-toast';
|
import { useToast } from './use-toast';
|
||||||
import { getErrorMessage, handleNonCriticalError } from '@/lib/errorHandler';
|
import { getErrorMessage, handleNonCriticalError, handleError } from '@/lib/errorHandler';
|
||||||
import { getSubmissionTypeLabel } from '@/lib/moderation/entities';
|
import { getSubmissionTypeLabel } from '@/lib/moderation/entities';
|
||||||
import { logger } from '@/lib/logger';
|
import { logger } from '@/lib/logger';
|
||||||
|
|
||||||
@@ -195,7 +195,7 @@ export const useModerationQueue = (config?: UseModerationQueueConfig) => {
|
|||||||
// Start countdown timer for restored lock
|
// Start countdown timer for restored lock
|
||||||
startLockTimer(expiresAt);
|
startLockTimer(expiresAt);
|
||||||
|
|
||||||
console.log('Lock state restored from database', {
|
logger.info('Lock state restored from database', {
|
||||||
submissionId: data.id,
|
submissionId: data.id,
|
||||||
expiresAt: expiresAt.toISOString(),
|
expiresAt: expiresAt.toISOString(),
|
||||||
});
|
});
|
||||||
@@ -203,8 +203,8 @@ export const useModerationQueue = (config?: UseModerationQueueConfig) => {
|
|||||||
}
|
}
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
// Log but don't show user toast (they haven't taken any action yet)
|
// Log but don't show user toast (they haven't taken any action yet)
|
||||||
console.debug('Failed to restore lock state', {
|
logger.debug('Failed to restore lock state', {
|
||||||
error: error instanceof Error ? error.message : String(error),
|
error: getErrorMessage(error),
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -608,10 +608,10 @@ export const useModerationQueue = (config?: UseModerationQueueConfig) => {
|
|||||||
|
|
||||||
return data;
|
return data;
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
toast({
|
handleError(error, {
|
||||||
title: 'Failed to Release Lock',
|
action: 'Superuser Release Lock',
|
||||||
description: getErrorMessage(error),
|
userId: user.id,
|
||||||
variant: 'destructive',
|
metadata: { submissionId }
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
} finally {
|
} finally {
|
||||||
@@ -647,10 +647,10 @@ export const useModerationQueue = (config?: UseModerationQueueConfig) => {
|
|||||||
|
|
||||||
return count;
|
return count;
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
toast({
|
handleError(error, {
|
||||||
title: 'Failed to Clear Locks',
|
action: 'Superuser Clear All Locks',
|
||||||
description: getErrorMessage(error),
|
userId: user.id,
|
||||||
variant: 'destructive',
|
metadata: { attemptedAction: 'bulk_release' }
|
||||||
});
|
});
|
||||||
return 0;
|
return 0;
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { FileText, Flag, AlertCircle, Activity, ShieldAlert } from 'lucide-react
|
|||||||
import { useUserRole } from '@/hooks/useUserRole';
|
import { useUserRole } from '@/hooks/useUserRole';
|
||||||
import { useAuth } from '@/hooks/useAuth';
|
import { useAuth } from '@/hooks/useAuth';
|
||||||
import { useRequireMFA } from '@/hooks/useRequireMFA';
|
import { useRequireMFA } from '@/hooks/useRequireMFA';
|
||||||
import { MFARequiredAlert } from '@/components/auth/MFARequiredAlert';
|
import { MFAGuard } from '@/components/auth/MFAGuard';
|
||||||
import { Card, CardContent } from '@/components/ui/card';
|
import { Card, CardContent } from '@/components/ui/card';
|
||||||
import { Badge } from '@/components/ui/badge';
|
import { Badge } from '@/components/ui/badge';
|
||||||
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/tabs';
|
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/tabs';
|
||||||
@@ -159,15 +159,6 @@ export default function AdminDashboard() {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// MFA enforcement
|
|
||||||
if (needsEnrollment) {
|
|
||||||
return (
|
|
||||||
<AdminLayout>
|
|
||||||
<MFARequiredAlert />
|
|
||||||
</AdminLayout>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const statCards = [
|
const statCards = [
|
||||||
{
|
{
|
||||||
label: 'Pending Submissions',
|
label: 'Pending Submissions',
|
||||||
@@ -200,6 +191,7 @@ export default function AdminDashboard() {
|
|||||||
lastUpdated={lastUpdated ?? undefined}
|
lastUpdated={lastUpdated ?? undefined}
|
||||||
isRefreshing={isRefreshing}
|
isRefreshing={isRefreshing}
|
||||||
>
|
>
|
||||||
|
<MFAGuard>
|
||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
<div>
|
<div>
|
||||||
<h1 className="text-2xl font-bold tracking-tight">Admin Dashboard</h1>
|
<h1 className="text-2xl font-bold tracking-tight">Admin Dashboard</h1>
|
||||||
@@ -307,6 +299,7 @@ export default function AdminDashboard() {
|
|||||||
</TabsContent>
|
</TabsContent>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</div>
|
</div>
|
||||||
|
</MFAGuard>
|
||||||
</AdminLayout>
|
</AdminLayout>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { useRef, useCallback } from 'react';
|
import { useRef, useCallback } from 'react';
|
||||||
import { useAdminGuard } from '@/hooks/useAdminGuard';
|
import { useAdminGuard } from '@/hooks/useAdminGuard';
|
||||||
import { MFARequiredAlert } from '@/components/auth/MFARequiredAlert';
|
import { MFAGuard } from '@/components/auth/MFAGuard';
|
||||||
import { AdminLayout } from '@/components/layout/AdminLayout';
|
import { AdminLayout } from '@/components/layout/AdminLayout';
|
||||||
import { ModerationQueue, ModerationQueueRef } from '@/components/moderation/ModerationQueue';
|
import { ModerationQueue, ModerationQueueRef } from '@/components/moderation/ModerationQueue';
|
||||||
import { QueueSkeleton } from '@/components/moderation/QueueSkeleton';
|
import { QueueSkeleton } from '@/components/moderation/QueueSkeleton';
|
||||||
@@ -57,14 +57,6 @@ export default function AdminModeration() {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needsMFA) {
|
|
||||||
return (
|
|
||||||
<AdminLayout>
|
|
||||||
<MFARequiredAlert />
|
|
||||||
</AdminLayout>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AdminLayout
|
<AdminLayout
|
||||||
onRefresh={handleRefresh}
|
onRefresh={handleRefresh}
|
||||||
@@ -72,6 +64,7 @@ export default function AdminModeration() {
|
|||||||
pollInterval={pollInterval}
|
pollInterval={pollInterval}
|
||||||
lastUpdated={lastUpdated ?? undefined}
|
lastUpdated={lastUpdated ?? undefined}
|
||||||
>
|
>
|
||||||
|
<MFAGuard>
|
||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
<div>
|
<div>
|
||||||
<h1 className="text-2xl font-bold tracking-tight">Moderation Queue</h1>
|
<h1 className="text-2xl font-bold tracking-tight">Moderation Queue</h1>
|
||||||
@@ -82,6 +75,7 @@ export default function AdminModeration() {
|
|||||||
|
|
||||||
<ModerationQueue ref={moderationQueueRef} />
|
<ModerationQueue ref={moderationQueueRef} />
|
||||||
</div>
|
</div>
|
||||||
|
</MFAGuard>
|
||||||
</AdminLayout>
|
</AdminLayout>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { useRef, useCallback } from 'react';
|
import { useRef, useCallback } from 'react';
|
||||||
import { useAdminGuard } from '@/hooks/useAdminGuard';
|
import { useAdminGuard } from '@/hooks/useAdminGuard';
|
||||||
import { MFARequiredAlert } from '@/components/auth/MFARequiredAlert';
|
import { MFAGuard } from '@/components/auth/MFAGuard';
|
||||||
import { AdminLayout } from '@/components/layout/AdminLayout';
|
import { AdminLayout } from '@/components/layout/AdminLayout';
|
||||||
import { ReportsQueue, ReportsQueueRef } from '@/components/moderation/ReportsQueue';
|
import { ReportsQueue, ReportsQueueRef } from '@/components/moderation/ReportsQueue';
|
||||||
import { QueueSkeleton } from '@/components/moderation/QueueSkeleton';
|
import { QueueSkeleton } from '@/components/moderation/QueueSkeleton';
|
||||||
@@ -58,14 +58,6 @@ export default function AdminReports() {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needsMFA) {
|
|
||||||
return (
|
|
||||||
<AdminLayout>
|
|
||||||
<MFARequiredAlert />
|
|
||||||
</AdminLayout>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AdminLayout
|
<AdminLayout
|
||||||
onRefresh={handleRefresh}
|
onRefresh={handleRefresh}
|
||||||
@@ -73,6 +65,7 @@ export default function AdminReports() {
|
|||||||
pollInterval={pollInterval}
|
pollInterval={pollInterval}
|
||||||
lastUpdated={lastUpdated ?? undefined}
|
lastUpdated={lastUpdated ?? undefined}
|
||||||
>
|
>
|
||||||
|
<MFAGuard>
|
||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
<div>
|
<div>
|
||||||
<h1 className="text-2xl font-bold tracking-tight">User Reports</h1>
|
<h1 className="text-2xl font-bold tracking-tight">User Reports</h1>
|
||||||
@@ -83,6 +76,7 @@ export default function AdminReports() {
|
|||||||
|
|
||||||
<ReportsQueue ref={reportsQueueRef} />
|
<ReportsQueue ref={reportsQueueRef} />
|
||||||
</div>
|
</div>
|
||||||
|
</MFAGuard>
|
||||||
</AdminLayout>
|
</AdminLayout>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useAdminGuard } from '@/hooks/useAdminGuard';
|
import { useAdminGuard } from '@/hooks/useAdminGuard';
|
||||||
import { MFARequiredAlert } from '@/components/auth/MFARequiredAlert';
|
import { MFAGuard } from '@/components/auth/MFAGuard';
|
||||||
import { AdminLayout } from '@/components/layout/AdminLayout';
|
import { AdminLayout } from '@/components/layout/AdminLayout';
|
||||||
import { UserManagement } from '@/components/admin/UserManagement';
|
import { UserManagement } from '@/components/admin/UserManagement';
|
||||||
import { Skeleton } from '@/components/ui/skeleton';
|
import { Skeleton } from '@/components/ui/skeleton';
|
||||||
@@ -44,16 +44,9 @@ export default function AdminUsers() {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needsMFA) {
|
|
||||||
return (
|
|
||||||
<AdminLayout>
|
|
||||||
<MFARequiredAlert />
|
|
||||||
</AdminLayout>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AdminLayout>
|
<AdminLayout>
|
||||||
|
<MFAGuard>
|
||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
<div>
|
<div>
|
||||||
<h1 className="text-2xl font-bold tracking-tight">User Management</h1>
|
<h1 className="text-2xl font-bold tracking-tight">User Management</h1>
|
||||||
@@ -64,6 +57,7 @@ export default function AdminUsers() {
|
|||||||
|
|
||||||
<UserManagement />
|
<UserManagement />
|
||||||
</div>
|
</div>
|
||||||
|
</MFAGuard>
|
||||||
</AdminLayout>
|
</AdminLayout>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user