Dental Care
This commit is contained in:
49
app/forbidden/forbidden.tsx
Normal file
49
app/forbidden/forbidden.tsx
Normal file
@@ -0,0 +1,49 @@
|
||||
import { Button } from "@/components/ui/button";
|
||||
import Link from "next/link";
|
||||
import { getCurrentUser } from "@/lib/auth-session/auth-server";
|
||||
import { redirect } from "next/navigation";
|
||||
|
||||
export default async function ForbiddenPage() {
|
||||
const user = await getCurrentUser();
|
||||
|
||||
// If not authenticated, redirect to sign-in
|
||||
if (!user) {
|
||||
redirect("/sign-in");
|
||||
}
|
||||
|
||||
// Determine the appropriate dashboard based on role
|
||||
const getDashboardUrl = () => {
|
||||
switch (user.role) {
|
||||
case "admin":
|
||||
return "/admin";
|
||||
case "dentist":
|
||||
return "/dentist";
|
||||
case "patient":
|
||||
return "/patient";
|
||||
default:
|
||||
return "/profile";
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<main className="flex grow items-center justify-center px-4 text-center">
|
||||
<div className="space-y-6">
|
||||
<div className="space-y-2">
|
||||
<h1 className="text-4xl font-bold">403</h1>
|
||||
<h2 className="text-2xl font-semibold">Access Denied</h2>
|
||||
<p className="text-muted-foreground">
|
||||
You don't have permission to access this page.
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex gap-4 justify-center">
|
||||
<Button asChild variant="default">
|
||||
<Link href={getDashboardUrl()}>Go to Dashboard</Link>
|
||||
</Button>
|
||||
<Button asChild variant="outline">
|
||||
<Link href="/">Go Home</Link>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
25
app/forbidden/unauthorized.tsx
Normal file
25
app/forbidden/unauthorized.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
"use client";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import Link from "next/link";
|
||||
import { usePathname } from "next/navigation";
|
||||
|
||||
export default function UnauthorizedPage() {
|
||||
const pathname = usePathname();
|
||||
|
||||
return (
|
||||
<main className="flex grow items-center justify-center px-4 text-center">
|
||||
<div className="space-y-6">
|
||||
<div className="space-y-2">
|
||||
<h1 className="text-2xl font-semibold">401 - Unauthorized</h1>
|
||||
<p className="text-muted-foreground">Please sign in to continue.</p>
|
||||
</div>
|
||||
<div>
|
||||
<Button asChild>
|
||||
<Link href={`/sign-in?redirect=${pathname}`}>Sign in</Link>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user