Spaces:
Runtime error
Runtime error
Download apps/web/src/lib/guards.ts from Oheha/cybully-api: direct link, hf CLI and curl.
- Browser
- Download file 441 Bytes
-
https://huggingface.co/spaces/Oheha/cybully-api/resolve/main/apps/web/src/lib/guards.ts
- Command line
-
hf download hf://spaces/Oheha/cybully-api/apps/web/src/lib/guards.ts
-
curl -L -o guards.ts https://huggingface.co/spaces/Oheha/cybully-api/resolve/main/apps/web/src/lib/guards.ts
441 Bytes
| import { redirect } from "next/navigation"; | |
| import { getSession } from "@/lib/auth"; | |
| export async function requireUser() { | |
| const session = await getSession(); | |
| if (!session?.user?.email || !session.accessToken) { | |
| redirect("/sign-in"); | |
| } | |
| return session; | |
| } | |
| export async function requireModerator() { | |
| const session = await requireUser(); | |
| if (session.user?.role !== "moderator") { | |
| redirect("/app"); | |
| } | |
| return session; | |
| } | |