Some checks are pending
E2E / Playwright e2e (push) Waiting to run
- Introduced turbopack alias for canvas in next.config.mjs. - Updated package.json scripts for development and branding tasks. - Added new dependencies for Tiptap extensions. - Implemented new demo layouts for agenda, contacts, drive, and mail applications. - Enhanced globals.css for improved theming and splash screen animations. - Added OAuth callback handling for drive mounts. - Updated layout components to integrate new demo shells and improve structure.
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
"use client"
|
|
|
|
import Link from "next/link"
|
|
import { useAuthReady } from "@/lib/api/use-auth-ready"
|
|
import { usePlatformAdminAccess } from "@/lib/auth/use-platform-admin-access"
|
|
import { Button } from "@/components/ui/button"
|
|
|
|
export function AdminAccessGuard({ children }: { children: React.ReactNode }) {
|
|
const { ready, authenticated } = useAuthReady()
|
|
const { isAdmin, adminReady } = usePlatformAdminAccess()
|
|
|
|
if (!ready) {
|
|
return (
|
|
<p className="text-sm text-muted-foreground">Chargement de la session…</p>
|
|
)
|
|
}
|
|
|
|
if (!authenticated) {
|
|
return (
|
|
<div className="rounded-lg border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-900 dark:border-amber-900/40 dark:bg-amber-950/30 dark:text-amber-200">
|
|
<p>Connectez-vous avec un compte administrateur pour accéder à cette interface.</p>
|
|
<Button asChild variant="outline" size="sm" className="mt-3">
|
|
<Link href="/login">Se connecter</Link>
|
|
</Button>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
if (!adminReady) {
|
|
return (
|
|
<p className="text-sm text-muted-foreground">Vérification des droits administrateur…</p>
|
|
)
|
|
}
|
|
|
|
if (!isAdmin) {
|
|
return (
|
|
<div className="rounded-lg border border-destructive/30 bg-destructive/5 px-4 py-3 text-sm text-destructive">
|
|
<p>Accès refusé. Votre compte ne dispose pas des droits d'administration.</p>
|
|
<Button asChild variant="outline" size="sm" className="mt-3">
|
|
<Link href="/mail">Retour à Ultimail</Link>
|
|
</Button>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
return <>{children}</>
|
|
}
|