import type { Metadata } from "next"; import Link from "next/link"; import { signInHref } from "@/lib/admin"; export const metadata: Metadata = { title: "Signing in", robots: { index: false, follow: false } }; /** What went wrong with a sign-in (the backend's auth/routes.ts sends people here with a code). */ const PROBLEMS: Record = { NO_ACCESS: { title: "No access to this website's admin", text: "You're signed in, but your account hasn't been given a role on this website. Ask the website's Owner to add you, then try again.", retry: true, }, TWO_FACTOR_NEEDED: { title: "Two-step sign-in needed", text: "Owners and Admins of this website sign in with a second step. Turn on two-step sign-in in your church account, then try again.", retry: true, }, ACCOUNTS_UNAVAILABLE: { title: "Signing in isn't available right now", text: "The website can't reach your church's sign-in at the moment. Please try again in a few minutes.", retry: true, }, EXPIRED: { title: "The sign-in took too long", text: "Please try again.", retry: true }, SIGNIN_FAILED: { title: "That didn't work", text: "Something went wrong while signing you in. Please try again.", retry: true }, }; export default async function Problem({ searchParams }: { searchParams: Promise> }) { const q = await searchParams; const code = typeof q.code === "string" ? q.code : ""; const returnTo = typeof q.returnTo === "string" && q.returnTo.startsWith("/") && !q.returnTo.startsWith("//") ? q.returnTo : "/admin"; const p = PROBLEMS[code] ?? PROBLEMS.SIGNIN_FAILED!; return (

{p.title}

{p.text}

{p.retry && ( Try again )} Go to the website
); }