Files
crosscode-platform/apps/website/frontend/src/app/auth/problem/page.tsx
T
joshuaandClaude Opus 5.5 58960b5e93 feat(website): crosscode website.sh and signing in through Accounts
crosscode: scripts/products/website.sh (ports 5300/3300, uploads in the
export), crosscode add <church> website (needs Accounts; www.<address>
or the Cross Code address), one install_app for Accounts and the
Website, env template copy, bats tests.

Backend: Hub client (protocol v2, product website), crosscode.link/1
with automatic connect to the church's Accounts, sign-in through
@crosscode/auth-client with the Website's own session and roles, the
first Owner from HUB_ADMIN_EMAIL (verified), 2FA for Owners and Admins,
back-channel logout, Accounts' user.* calls, and the church export.
Frontend: admin sign-in/out and the sign-in problem page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 09:27:07 +02:00

50 lines
2.2 KiB
TypeScript

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<string, { title: string; text: string; retry: boolean }> = {
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<Record<string, string | string[] | undefined>> }) {
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 (
<main className="mx-auto max-w-xl px-4 py-16">
<h1 className="text-2xl font-semibold">{p.title}</h1>
<p className="mt-2 text-gray-600">{p.text}</p>
<div className="mt-6 flex gap-3">
{p.retry && (
<a href={signInHref(returnTo)} className="rounded bg-brand px-4 py-2 text-sm text-white hover:bg-brand-dark">
Try again
</a>
)}
<Link href="/" className="rounded border border-gray-300 px-4 py-2 text-sm hover:bg-gray-50">
Go to the website
</Link>
</div>
</main>
);
}