-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathpage.tsx
37 lines (35 loc) · 836 Bytes
/
page.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { LogoutButton } from "./components";
import Link from "next/link";
import { getCurrentSession } from "@/lib/server/session";
import { redirect } from "next/navigation";
import { globalGETRateLimit } from "@/lib/server/request";
export default function Page() {
if (!globalGETRateLimit()) {
return "Too many requests";
}
const { session, user } = getCurrentSession();
if (session === null) {
return redirect("/login");
}
if (!user.emailVerified) {
return redirect("/verify-email");
}
if (!user.registered2FA) {
return redirect("/2fa/setup");
}
if (!session.twoFactorVerified) {
return redirect("/2fa");
}
return (
<>
<header>
<Link href="/">Home</Link>
<Link href="/settings">Settings</Link>
</header>
<main>
<h1>Hi {user.username}!</h1>
<LogoutButton />
</main>
</>
);
}