Download src/app/api/auth/status/route.js from heyeyydss/api9nin: direct link, hf CLI and curl.
- Browser
- Download file 1.61 kB
-
https://huggingface.co/spaces/heyeyydss/api9nin/resolve/main/src/app/api/auth/status/route.js
- Command line
-
hf download hf://spaces/heyeyydss/api9nin/src/app/api/auth/status/route.js
-
curl -L -o route.js https://huggingface.co/spaces/heyeyydss/api9nin/resolve/main/src/app/api/auth/status/route.js
1.61 kB
| import { NextResponse } from "next/server"; | |
| import { cookies } from "next/headers"; | |
| import { getSettings } from "@/lib/localDb"; | |
| import { isOidcConfigured } from "@/lib/auth/oidc"; | |
| import { getDashboardAuthSession } from "@/lib/auth/dashboardSession"; | |
| export async function GET() { | |
| try { | |
| const settings = await getSettings(); | |
| const cookieStore = await cookies(); | |
| const session = await getDashboardAuthSession(cookieStore.get("auth_token")?.value); | |
| const requireLogin = settings.requireLogin !== false; | |
| const authMode = settings.authMode || "password"; | |
| const oidcName = String(session?.oidcName || "").trim(); | |
| const oidcEmail = String(session?.oidcEmail || "").trim(); | |
| const displayName = oidcName || oidcEmail || (session?.oidc ? "OIDC user" : "Password user"); | |
| const loginMethod = session?.oidc ? "OIDC" : "Password"; | |
| return NextResponse.json({ | |
| requireLogin, | |
| authMode, | |
| oidcConfigured: isOidcConfigured(settings), | |
| oidcLoginLabel: (settings.oidcLoginLabel || "Sign in with OIDC").trim() || "Sign in with OIDC", | |
| hasPassword: !!settings.password, | |
| displayName, | |
| loginMethod, | |
| oidcName: oidcName || null, | |
| oidcEmail: oidcEmail || null, | |
| oidcLogin: !!session?.oidc, | |
| }); | |
| } catch { | |
| return NextResponse.json({ | |
| requireLogin: true, | |
| authMode: "password", | |
| oidcConfigured: false, | |
| oidcLoginLabel: "Sign in with OIDC", | |
| hasPassword: false, | |
| displayName: "Password user", | |
| loginMethod: "Password", | |
| oidcName: null, | |
| oidcEmail: null, | |
| oidcLogin: false, | |
| }); | |
| } | |
| } | |