"use client"; import React, { useEffect, useState } from "react"; import { fetchAuthMode, safePath, signInHref, type AuthMode } from "@/lib/signIn"; type Kind = "login" | "register" | "forgot" | "reset" | "activate"; /** * Cross Events' own sign-in pages (3.0.0). With sign-in through Accounts, the sign-in, sign-up and * forgot-password pages forward there (keeping where to come back to), and old reset and activation * links say sign-in has moved. Otherwise (`local`, or `?local=1` from the backend) the page as before. */ export function AccountsGate({ kind, children }: { kind: Kind; children: React.ReactNode }) { const [mode, setMode] = useState(null); useEffect(() => { let alive = true; const params = new URLSearchParams(window.location.search); if (params.get("local") === "1") { setMode("local"); return; } fetchAuthMode().then((m) => { if (!alive) return; if (m === "accounts" && (kind === "login" || kind === "register" || kind === "forgot")) { window.location.replace(signInHref(safePath(params.get("redirect")), { signUp: kind === "register" })); return; } setMode(m); }); return () => { alive = false; }; }, [kind]); if (mode === null) { return
Loading…
; } if (mode === "accounts") return ; return <>{children}; } function SignInMoved({ kind }: { kind: Kind }) { return (

Sign-in has moved

{kind === "activate" ? "You now sign in with your church account. To get started, use “Forgot your password?” there with your email address to choose a password." : "You now sign in with your church account, so this link no longer works. Use “Forgot your password?” there to choose a new one."}

Sign in
); }