Cross Events 3.0.0: sign-in through the church's Accounts
Settings -> Sign-in: check, move (everyone into Accounts with their password hashes and authenticator apps, count/hash check, then switch) and undo for 14 days. Sign-in through auth-client with a one-time handoff to Events' own token; staff roles stepped up to mfa; sign-out and back-channel logout; user.updated/export/deleted; admin 2FA reset, unlock and profile changes via Accounts; /login, /register, /forgot-password forward once moved; Events' own sign-in endpoints answer SIGN_IN_MOVED. User.accountId, AccountsSignIn. npm run test:accounts runs Events' code against the real Accounts app (11 tests); 5 new Jest tests. MIGRATING-TO-3.md, plan "Changes while building". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@crosscode/events-frontend",
|
||||
"version": "2.4.1",
|
||||
"version": "3.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"use client";
|
||||
import { AccountsGate } from "@/components/auth/AccountsGate";
|
||||
import { useState } from "react";
|
||||
import { Navbar } from "@/components/layout/Navbar";
|
||||
import { Footer } from "@/components/layout/Footer";
|
||||
@@ -6,7 +7,7 @@ import { KeyRound } from "lucide-react";
|
||||
import { errorMessage } from "@/lib/utils";
|
||||
import { apiV2Data } from "@/lib/apiV2";
|
||||
|
||||
export default function ForgotPasswordPage() {
|
||||
function ForgotPasswordPageLocal() {
|
||||
const [email, setEmail] = useState("");
|
||||
const [status, setStatus] = useState<string | null>(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
@@ -59,3 +60,8 @@ export default function ForgotPasswordPage() {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// 3.0.0: forwards to the church's Accounts once sign-in has moved there (components/auth/AccountsGate).
|
||||
export default function ForgotPasswordPage() {
|
||||
return <AccountsGate kind="forgot"><ForgotPasswordPageLocal /></AccountsGate>;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
"use client";
|
||||
import { AccountsGate } from "@/components/auth/AccountsGate";
|
||||
import React, { Suspense } from "react";
|
||||
import { Navbar } from "@/components/layout/Navbar";
|
||||
import { Footer } from "@/components/layout/Footer";
|
||||
import { LoginForm } from "@/components/auth/LoginForm";
|
||||
import { LogIn } from "lucide-react";
|
||||
|
||||
export default function LoginPage() {
|
||||
function LoginPageLocal() {
|
||||
return (
|
||||
<div className="min-h-screen flex flex-col">
|
||||
<Navbar />
|
||||
@@ -29,3 +30,8 @@ export default function LoginPage() {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// 3.0.0: forwards to the church's Accounts once sign-in has moved there (components/auth/AccountsGate).
|
||||
export default function LoginPage() {
|
||||
return <AccountsGate kind="login"><LoginPageLocal /></AccountsGate>;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
"use client";
|
||||
import { AccountsGate } from "@/components/auth/AccountsGate";
|
||||
import React, { Suspense } from "react";
|
||||
import { Navbar } from "@/components/layout/Navbar";
|
||||
import { Footer } from "@/components/layout/Footer";
|
||||
import { RegisterForm } from "@/components/auth/RegisterForm";
|
||||
import { UserPlus } from "lucide-react";
|
||||
|
||||
export default function RegisterPage() {
|
||||
function RegisterPageLocal() {
|
||||
return (
|
||||
<div className="min-h-screen flex flex-col">
|
||||
<Navbar />
|
||||
@@ -29,3 +30,8 @@ export default function RegisterPage() {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// 3.0.0: forwards to the church's Accounts once sign-in has moved there (components/auth/AccountsGate).
|
||||
export default function RegisterPage() {
|
||||
return <AccountsGate kind="register"><RegisterPageLocal /></AccountsGate>;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"use client";
|
||||
import { AccountsGate } from "@/components/auth/AccountsGate";
|
||||
import React, { Suspense, useMemo, useState } from "react";
|
||||
import Link from "next/link";
|
||||
import { Navbar } from "@/components/layout/Navbar";
|
||||
@@ -89,10 +90,14 @@ function ActivateAccountContent() {
|
||||
);
|
||||
}
|
||||
|
||||
export default function ActivateAccountPage() {
|
||||
function ActivateAccountPageLocal() {
|
||||
return (
|
||||
<Suspense fallback={<div className="p-6">Loading...</div>}>
|
||||
<ActivateAccountContent />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
}
|
||||
// 3.0.0: forwards to the church's Accounts once sign-in has moved there (components/auth/AccountsGate).
|
||||
export default function ActivateAccountPage() {
|
||||
return <AccountsGate kind="activate"><ActivateAccountPageLocal /></AccountsGate>;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { API_BASE } from "@/lib/api";
|
||||
import { saveToken } from "@/lib/auth";
|
||||
import { safePath, signInHref } from "@/lib/signIn";
|
||||
|
||||
/**
|
||||
* Back from the church's Accounts (3.0.0, docs/EVENTS-3.0-PLAN.md §3): the one-time code in the
|
||||
* address's fragment (never sent to a server or in a Referer) is swapped for Events' own token,
|
||||
* then on to the page the person started on.
|
||||
*/
|
||||
export default function SignInCompletePage() {
|
||||
const [failed, setFailed] = useState<string | null>(null);
|
||||
useEffect(() => {
|
||||
const code = window.location.hash.slice(1);
|
||||
// Out of the address bar and the history straight away.
|
||||
window.history.replaceState(null, "", "/auth/complete");
|
||||
if (!code) {
|
||||
setFailed("This sign-in link has already been used.");
|
||||
return;
|
||||
}
|
||||
fetch(`${API_BASE}/api/auth/handoff`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ code }) })
|
||||
.then(async (r) => {
|
||||
const j = await r.json().catch(() => null);
|
||||
if (!r.ok || !j?.data?.token) throw new Error(j?.error?.message || "This sign-in has expired. Please sign in again.");
|
||||
saveToken(j.data.token);
|
||||
// A full page load, so the whole app starts signed in.
|
||||
window.location.replace(safePath(j.data.returnTo));
|
||||
})
|
||||
.catch((e: Error) => setFailed(e.message));
|
||||
}, []);
|
||||
return (
|
||||
<div className="min-h-screen flex items-center justify-center p-6">
|
||||
{failed ? (
|
||||
<div className="w-full max-w-md border rounded-2xl p-8 bg-white shadow-sm">
|
||||
<h1 className="text-xl font-semibold text-gray-900 mb-2">We couldn't sign you in</h1>
|
||||
<p className="text-sm text-gray-600 mb-6">{failed}</p>
|
||||
<a href={signInHref("/dashboard")} className="inline-block w-full text-center px-4 py-2.5 rounded-lg bg-brand-600 text-white text-sm font-medium">Sign in again</a>
|
||||
</div>
|
||||
) : (
|
||||
<p className="text-sm text-gray-500" role="status">Signing you in…</p>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
"use client";
|
||||
|
||||
import React, { Suspense } from "react";
|
||||
import { useSearchParams } from "next/navigation";
|
||||
import { Navbar } from "@/components/layout/Navbar";
|
||||
import { Footer } from "@/components/layout/Footer";
|
||||
import { safePath, signInHref } from "@/lib/signIn";
|
||||
|
||||
/** When signing in through the church's Accounts didn't work (3.0.0): what happened, and Try again. */
|
||||
const MESSAGES: Record<string, { title: string; text: string; retry?: boolean }> = {
|
||||
EXPIRED: { title: "That sign-in expired", text: "It took too long, or it was opened in another browser. Please try again.", retry: true },
|
||||
ACCOUNTS_UNAVAILABLE: { title: "Sign-in isn’t available right now", text: "We couldn’t reach the church’s sign-in. Please try again in a minute.", retry: true },
|
||||
START_FAILED: { title: "Sign-in isn’t available right now", text: "Please try again in a minute.", retry: true },
|
||||
FINISH_FAILED: { title: "We couldn’t finish signing you in", text: "Please try again.", retry: true },
|
||||
EVENTS_OFF: { title: "Your access to events is turned off", text: "Your church account is fine, but you can’t use this site at the moment. Please ask the church office." },
|
||||
MFA_REQUIRED: { title: "Two-step sign-in is needed", text: "Your role here needs a second step when you sign in. Please try again and set it up when asked.", retry: true },
|
||||
EMAIL_IN_USE: { title: "That email address belongs to someone else here", text: "Please ask the church office to sort it out." },
|
||||
EMAIL_NOT_VERIFIED: { title: "Please confirm your email address", text: "Confirm the email address on your church account, then sign in again.", retry: true },
|
||||
};
|
||||
|
||||
function Problem() {
|
||||
const search = useSearchParams();
|
||||
const m = MESSAGES[search.get("code") || ""] ?? { title: "Something went wrong signing in", text: "Please try again.", retry: true };
|
||||
return (
|
||||
<div className="w-full max-w-md border rounded-2xl p-8 bg-white shadow-sm">
|
||||
<h1 className="text-xl font-semibold text-gray-900 mb-2">{m.title}</h1>
|
||||
<p className="text-sm text-gray-600 mb-6">{m.text}</p>
|
||||
{m.retry && <a href={signInHref(safePath(search.get("returnTo"), "/"))} className="inline-block w-full text-center px-4 py-2.5 rounded-lg bg-brand-600 text-white text-sm font-medium">Try again</a>}
|
||||
<a href="/" className="block mt-3 text-center text-sm text-gray-500 underline">Home page</a>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default function SignInProblemPage() {
|
||||
return (
|
||||
<div className="min-h-screen flex flex-col">
|
||||
<Navbar />
|
||||
<main className="flex-1 flex items-center justify-center p-6">
|
||||
<Suspense fallback={<div />}><Problem /></Suspense>
|
||||
</main>
|
||||
<Footer />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import { ApiError, resolveToApiOrigin } from "@/lib/api";
|
||||
import { apiV2Raw, apiV2Data } from "@/lib/apiV2";
|
||||
import { useSiteSettings } from "@/contexts/SiteSettingsContext";
|
||||
import { useDismissingState } from "@/hooks/useDismissingState";
|
||||
import { Building2, Palette, Bell, Mail, Scale, MessageCircle, CreditCard, DatabaseBackup, Timer, KeyRound, MapPinned, type LucideIcon, Webhook, Sparkles, Link2 } from "lucide-react";
|
||||
import { Building2, Palette, Bell, Mail, Scale, MessageCircle, CreditCard, DatabaseBackup, Timer, KeyRound, MapPinned, type LucideIcon, Webhook, Sparkles, Link2, LogIn } from "lucide-react";
|
||||
import { ColorPickerField } from "@/components/admin/ColorPickerField";
|
||||
import { BrandingPreviewPanel } from "@/components/admin/BrandingPreviewPanel";
|
||||
import { BackupsTab } from "@/components/admin/BackupsTab";
|
||||
@@ -18,6 +18,7 @@ import { LicenceTab } from "@/components/admin/LicenceTab";
|
||||
import { WebhooksTab } from "@/components/admin/WebhooksTab";
|
||||
import { AiTab } from "@/components/admin/AiTab";
|
||||
import { LinkedProductsTab } from "@/components/admin/LinkedProductsTab";
|
||||
import { SignInTab } from "@/components/admin/SignInTab";
|
||||
import { CampusesTab } from "@/components/admin/CampusesTab";
|
||||
import { extractDominantColors } from "@/lib/extractColors";
|
||||
import { mapsSearchUrl } from "@/lib/maps";
|
||||
@@ -26,7 +27,7 @@ import { BackLink } from "@/components/shared/BackLink";
|
||||
import { uploadImage } from "@/lib/eventSetup";
|
||||
import { useExternalEffect } from "@/lib/hooks";
|
||||
|
||||
type TabId = "organisation" | "campuses" | "branding" | "notifications" | "email" | "legal" | "whatsapp" | "payments" | "webhooks" | "linked" | "backups" | "jobs" | "licence" | "ai";
|
||||
type TabId = "organisation" | "campuses" | "branding" | "notifications" | "email" | "legal" | "whatsapp" | "payments" | "webhooks" | "linked" | "signin" | "backups" | "jobs" | "licence" | "ai";
|
||||
|
||||
const TABS: { id: TabId; label: string; icon: LucideIcon }[] = [
|
||||
{ id: "organisation", label: "Organisation", icon: Building2 },
|
||||
@@ -39,6 +40,7 @@ const TABS: { id: TabId; label: string; icon: LucideIcon }[] = [
|
||||
{ id: "payments", label: "Payments", icon: CreditCard },
|
||||
{ id: "webhooks", label: "Webhooks", icon: Webhook },
|
||||
{ id: "linked", label: "Linked products", icon: Link2 },
|
||||
{ id: "signin", label: "Sign-in", icon: LogIn },
|
||||
{ id: "backups", label: "Backups", icon: DatabaseBackup },
|
||||
{ id: "jobs", label: "Background jobs", icon: Timer },
|
||||
{ id: "licence", label: "Licence", icon: KeyRound },
|
||||
@@ -721,6 +723,7 @@ function SiteSettingsPageInner() {
|
||||
{activeTab === "backups" && <BackupsTab active={activeTab === "backups"} />}
|
||||
{activeTab === "webhooks" && <WebhooksTab active={activeTab === "webhooks"} />}
|
||||
{activeTab === "linked" && <LinkedProductsTab active={activeTab === "linked"} />}
|
||||
{activeTab === "signin" && <SignInTab active={activeTab === "signin"} />}
|
||||
{activeTab === "jobs" && <JobsTab active={activeTab === "jobs"} />}
|
||||
{activeTab === "licence" && <LicenceTab active={activeTab === "licence"} />}
|
||||
{activeTab === "ai" && <AiTab active={activeTab === "ai"} />}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"use client";
|
||||
import { useAuthInfo } from "@/components/auth/ChurchAccountNotice";
|
||||
|
||||
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
@@ -39,6 +40,9 @@ const TWO_FACTOR_LABEL: Record<"email" | "whatsapp" | "authenticator", string> =
|
||||
|
||||
export default function AdminUsersPage() {
|
||||
const { user, loading, token } = useAuth();
|
||||
// 3.0.0: signed in through the church's Accounts, 2FA and lockouts are reset there.
|
||||
const authInfo = useAuthInfo();
|
||||
const viaAccounts = authInfo?.mode === "accounts";
|
||||
const router = useRouter();
|
||||
|
||||
const isAdmin = useMemo(() => user?.role === "admin", [user]);
|
||||
@@ -234,15 +238,25 @@ export default function AdminUsersPage() {
|
||||
const message = role === "admin" || role === "supervisor"
|
||||
? `Reset two-factor authentication for ${name}? Their sessions end, and they'll set it up again with a new code at their next login.`
|
||||
: `Turn off two-factor authentication for ${name}? They will be able to log in with just their password until they turn it back on.`;
|
||||
if (!confirm(message)) return;
|
||||
if (!confirm(viaAccounts ? `Reset two-step sign-in for ${name} on their church account? They're signed out everywhere and set it up again at their next sign-in.` : message)) return;
|
||||
try {
|
||||
await apiV2Data("patch", "/users/{id}", { params: { id: id }, authToken: token, body: { twoFactorEnabled: false } });
|
||||
if (viaAccounts) await apiV2Data("post", "/users/{id}/account/reset-two-factor", { params: { id }, authToken: token });
|
||||
else await apiV2Data("patch", "/users/{id}", { params: { id: id }, authToken: token, body: { twoFactorEnabled: false } });
|
||||
await loadUsers(page);
|
||||
} catch (e) {
|
||||
setError(errorMessage(e) || "Failed to reset two-factor authentication");
|
||||
}
|
||||
};
|
||||
|
||||
const unlockAccount = async (id: string, name: string) => {
|
||||
try {
|
||||
await apiV2Data("post", "/users/{id}/account/unlock", { params: { id }, authToken: token });
|
||||
alert(`${name} can sign in again.`);
|
||||
} catch (e) {
|
||||
setError(errorMessage(e) || "Failed to unlock the account");
|
||||
}
|
||||
};
|
||||
|
||||
const deactivate = async (id: string) => {
|
||||
if (!confirm("Deactivate this user? Their account will be disabled.")) return;
|
||||
try {
|
||||
@@ -447,7 +461,10 @@ export default function AdminUsersPage() {
|
||||
{u.twoFactorEnabled && (
|
||||
<button className="px-2 py-1 text-xs rounded bg-amber-500 text-white hover:bg-amber-600" onClick={() => resetTwoFactor(u.id, u.name, u.role)} title={u.role === "admin" || u.role === "supervisor" ? "Reset two-factor authentication — they set it up again at their next login" : "Turn off two-factor authentication for a user who can no longer receive their codes"}>Reset 2FA</button>
|
||||
)}
|
||||
<button className="px-2 py-1 text-xs rounded bg-orange-500 text-white hover:bg-orange-600" onClick={() => deactivate(u.id)} title="Deactivate account">Deactivate</button>
|
||||
{viaAccounts && (
|
||||
<button className="px-2 py-1 text-xs rounded bg-gray-100 hover:bg-gray-200" onClick={() => unlockAccount(u.id, u.name)} title="After too many wrong passwords: let them try again now">Unlock</button>
|
||||
)}
|
||||
<button className="px-2 py-1 text-xs rounded bg-orange-500 text-white hover:bg-orange-600" onClick={() => deactivate(u.id)} title={viaAccounts ? "Stop them using Cross Events (their church account stays)" : "Deactivate account"}>Deactivate</button>
|
||||
<button className="px-2 py-1 text-xs rounded bg-red-700 text-white hover:bg-red-800" onClick={() => deleteUserData(u.id, u.name)} title="Erase personal data">Delete data</button>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"use client";
|
||||
import { ChurchAccountNotice, useAuthInfo } from "@/components/auth/ChurchAccountNotice";
|
||||
|
||||
import React, { useCallback, useState } from "react";
|
||||
import Link from "next/link";
|
||||
@@ -77,6 +78,10 @@ function Toggle({ label, hint, checked, disabled, onChange }: { label: string; h
|
||||
|
||||
export default function PrivacyCentrePage() {
|
||||
const { token, logout } = useAuth();
|
||||
// 3.0.0: signed in through the church's Accounts, news choices, "download my data" (with this
|
||||
// site's part in it) and deleting the account are on the church account.
|
||||
const authInfo = useAuthInfo();
|
||||
const viaAccounts = authInfo?.mode === "accounts";
|
||||
const [info, setInfo] = useState<PrivacyInfo | null>(null);
|
||||
const [loadError, setLoadError] = useState<string | null>(null);
|
||||
|
||||
@@ -202,7 +207,14 @@ export default function PrivacyCentrePage() {
|
||||
|
||||
<div className="grid lg:grid-cols-2 gap-6 items-start">
|
||||
<div className="space-y-6">
|
||||
{viaAccounts && (
|
||||
<ChurchAccountNotice
|
||||
accountUrl={authInfo?.accountUrl ?? null}
|
||||
what="Your news choices, downloading everything the church holds about you (including your events, tickets and payments here), and deleting your account are on your church account, for all the church's sites and apps at once."
|
||||
/>
|
||||
)}
|
||||
{/* ── News & announcements ───────────────────────────────────────── */}
|
||||
{!viaAccounts && (<>
|
||||
<section className="border rounded-xl p-5 bg-white shadow-sm">
|
||||
<SectionHeader icon={Megaphone} title="News & announcements" />
|
||||
<p className="text-sm text-gray-500 mb-4">
|
||||
@@ -255,6 +267,7 @@ export default function PrivacyCentrePage() {
|
||||
{downloadMsg && <Alert msg={downloadMsg} />}
|
||||
</section>
|
||||
|
||||
</>)}
|
||||
{/* ── My requests ────────────────────────────────────────────────── */}
|
||||
{info && info.requests.length > 0 && (
|
||||
<section className="border rounded-xl p-5 bg-white shadow-sm">
|
||||
@@ -300,6 +313,7 @@ export default function PrivacyCentrePage() {
|
||||
</section>
|
||||
|
||||
{/* ── Delete my account ──────────────────────────────────────────── */}
|
||||
{!viaAccounts && (
|
||||
<section className="border border-red-200 rounded-xl p-5 bg-white shadow-sm">
|
||||
<SectionHeader icon={Trash2} title="Delete my account" tone="red" />
|
||||
<p className="text-sm text-gray-500 mb-4">
|
||||
@@ -337,6 +351,7 @@ export default function PrivacyCentrePage() {
|
||||
)}
|
||||
{deleteMsg && <Alert msg={deleteMsg} />}
|
||||
</section>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"use client";
|
||||
import { ChurchAccountNotice, useAuthInfo } from "@/components/auth/ChurchAccountNotice";
|
||||
|
||||
import React, { useCallback, useEffect, useState } from "react";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
@@ -50,6 +51,10 @@ const SectionHeader = ({ icon: Icon, title, tone = "brand" }: { icon: typeof Use
|
||||
export default function UserProfilePage() {
|
||||
const { user, token, logout, updateToken } = useAuth();
|
||||
const router = useRouter();
|
||||
// 3.0.0: signed in through the church's Accounts, the details, password, two-step sign-in and
|
||||
// closing the account are on the church account.
|
||||
const authInfo = useAuthInfo();
|
||||
const viaAccounts = authInfo?.mode === "accounts";
|
||||
|
||||
useEffect(() => {
|
||||
if (!user && !token) router.replace("/login");
|
||||
@@ -372,16 +377,21 @@ export default function UserProfilePage() {
|
||||
<form onSubmit={saveProfile} className="space-y-4">
|
||||
<div>
|
||||
<label htmlFor="profile-full-name" className="block text-sm font-medium text-gray-700 mb-1">Full name</label>
|
||||
<input id="profile-full-name" className={inputCls} value={name} onChange={e => setName(e.target.value)} required />
|
||||
<input id="profile-full-name" className={inputCls} value={name} onChange={e => setName(e.target.value)} required readOnly={viaAccounts} />
|
||||
</div>
|
||||
<div>
|
||||
<label htmlFor="profile-email-address" className="block text-sm font-medium text-gray-700 mb-1">Email address</label>
|
||||
<input id="profile-email-address" type="email" className={inputCls} value={email} onChange={e => setEmail(e.target.value)} required />
|
||||
<input id="profile-email-address" type="email" className={inputCls} value={email} onChange={e => setEmail(e.target.value)} required readOnly={viaAccounts} />
|
||||
</div>
|
||||
<div>
|
||||
<label htmlFor="profile-phone-number" className="block text-sm font-medium text-gray-700 mb-1">Phone number</label>
|
||||
<input id="profile-phone-number" type="tel" className={inputCls} value={phone} onChange={e => setPhone(e.target.value)} placeholder="e.g. 082 123 4567" />
|
||||
<input id="profile-phone-number" type="tel" className={inputCls} value={phone} onChange={e => setPhone(e.target.value)} placeholder="e.g. 082 123 4567" readOnly={viaAccounts} />
|
||||
</div>
|
||||
{viaAccounts && (
|
||||
<p className="text-xs text-gray-500">
|
||||
Your name, email and phone are on your church account{authInfo?.accountUrl ? <>: <a href={authInfo.accountUrl} className="text-brand-600 hover:underline">change them there</a></> : null}. Changes show here the next time you sign in.
|
||||
</p>
|
||||
)}
|
||||
|
||||
{campusInfo.enabled && campusInfo.campuses.length > 0 && (
|
||||
<div>
|
||||
@@ -443,6 +453,13 @@ export default function UserProfilePage() {
|
||||
</div>
|
||||
|
||||
<div className="space-y-6">
|
||||
{viaAccounts && (
|
||||
<ChurchAccountNotice
|
||||
accountUrl={authInfo?.accountUrl ?? null}
|
||||
what="Your password, two-step sign-in, recovery codes, recent sign-ins and closing your account are on your church account, the same one you use for the church's other sites and apps."
|
||||
/>
|
||||
)}
|
||||
{!viaAccounts && (<>
|
||||
{/* ── Password ─────────────────────────────────────────────────── */}
|
||||
<section className="border rounded-xl p-5 bg-white shadow-sm">
|
||||
<SectionHeader icon={Lock} title="Change password" />
|
||||
@@ -706,6 +723,7 @@ export default function UserProfilePage() {
|
||||
</form>
|
||||
)}
|
||||
</section>
|
||||
</>)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"use client";
|
||||
import { AccountsGate } from "@/components/auth/AccountsGate";
|
||||
import React, { Suspense, useMemo, useState } from "react";
|
||||
import { Navbar } from "@/components/layout/Navbar";
|
||||
import { Footer } from "@/components/layout/Footer";
|
||||
@@ -68,10 +69,15 @@ function ResetPasswordContent() {
|
||||
);
|
||||
}
|
||||
|
||||
export default function ResetPasswordPage() {
|
||||
function ResetPasswordPageLocal() {
|
||||
return (
|
||||
<Suspense fallback={<div className="p-6">Loading...</div>}>
|
||||
<ResetPasswordContent />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
|
||||
// 3.0.0: forwards to the church's Accounts once sign-in has moved there (components/auth/AccountsGate).
|
||||
export default function ResetPasswordPage() {
|
||||
return <AccountsGate kind="reset"><ResetPasswordPageLocal /></AccountsGate>;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { LogIn } from "lucide-react";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
import { apiV2, type V2Result } from "@/lib/apiV2";
|
||||
import { errorMessage } from "@/lib/utils";
|
||||
|
||||
type Status = V2Result<"/settings/sign-in", "get">["data"];
|
||||
type Check = V2Result<"/settings/sign-in/check", "post">["data"];
|
||||
type Report = { created: number; linked: { name: string; email: string }[]; refused: { name: string; email: string; reason: string }[]; skipped: number; accountsAdmins: { name: string }[]; by: string; movedAt: string };
|
||||
|
||||
const when = (iso: string | null | undefined) =>
|
||||
iso ? new Date(iso).toLocaleString("en-ZA", { day: "numeric", month: "long", year: "numeric", hour: "2-digit", minute: "2-digit" }) : "";
|
||||
|
||||
/**
|
||||
* Site settings → Sign-in (3.0.0, docs/EVENTS-3.0-PLAN.md §5): where people sign in, and moving
|
||||
* sign-in to the church's Accounts: Check (nothing changes), Move (with which admins also manage
|
||||
* Accounts), and Undo for 14 days.
|
||||
*/
|
||||
export function SignInTab({ active }: { active: boolean }) {
|
||||
const { token } = useAuth();
|
||||
const [status, setStatus] = useState<Status | null>(null);
|
||||
const [checked, setChecked] = useState<Check | null>(null);
|
||||
const [admins, setAdmins] = useState<Set<string>>(new Set());
|
||||
const [keepAccountsNotices, setKeepAccountsNotices] = useState(false);
|
||||
const [busy, setBusy] = useState<string | null>(null);
|
||||
const [msg, setMsg] = useState<{ ok: boolean; text: string } | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!active || !token) return;
|
||||
let alive = true;
|
||||
apiV2("get", "/settings/sign-in", { authToken: token })
|
||||
.then(({ data }) => { if (alive) setStatus(data); })
|
||||
.catch((e) => { if (alive) setMsg({ ok: false, text: errorMessage(e) || "Could not load the sign-in settings." }); });
|
||||
return () => { alive = false; };
|
||||
}, [active, token]);
|
||||
|
||||
if (!token) return null;
|
||||
if (!status) return msg ? <p className="text-sm text-red-700">{msg.text}</p> : <p className="text-sm text-gray-500">Loading…</p>;
|
||||
const auth = { authToken: token };
|
||||
|
||||
const runCheck = async () => {
|
||||
setBusy("check");
|
||||
setMsg(null);
|
||||
try {
|
||||
const { data } = await apiV2("post", "/settings/sign-in/check", auth);
|
||||
setChecked(data);
|
||||
setAdmins(new Set(data.admins.map((a) => a.id)));
|
||||
} catch (e) {
|
||||
setMsg({ ok: false, text: errorMessage(e) || "The check didn't work." });
|
||||
}
|
||||
setBusy(null);
|
||||
};
|
||||
|
||||
const runMove = async () => {
|
||||
if (!checked) return;
|
||||
if (!window.confirm(`Move sign-in to your church's Accounts now? ${checked.toMove} people will sign in there from now on, with the passwords they have today.`)) return;
|
||||
setBusy("move");
|
||||
setMsg(null);
|
||||
try {
|
||||
const { data } = await apiV2("post", "/settings/sign-in/move", { ...auth, body: { adminIds: [...admins], ...(checked.noticeConflict ? { keepAccountsNotices } : {}) } });
|
||||
setStatus(data);
|
||||
setChecked(null);
|
||||
setMsg({ ok: true, text: "Sign-in now goes through your church's Accounts. People already signed in stay signed in." });
|
||||
} catch (e) {
|
||||
setMsg({ ok: false, text: errorMessage(e) || "The move didn't finish. Nothing was switched; you can try again." });
|
||||
}
|
||||
setBusy(null);
|
||||
};
|
||||
|
||||
const runUndo = async () => {
|
||||
if (!window.confirm("Go back to Cross Events' own sign-in? People sign in with the password they had at the move. Changes made in Accounts since then (a new password, two-step sign-in) don't come back here.")) return;
|
||||
setBusy("undo");
|
||||
setMsg(null);
|
||||
try {
|
||||
const { data } = await apiV2("post", "/settings/sign-in/undo", auth);
|
||||
setStatus(data);
|
||||
setMsg({ ok: true, text: "Sign-in is back in Cross Events." });
|
||||
} catch (e) {
|
||||
setMsg({ ok: false, text: errorMessage(e) || "Undo didn't work." });
|
||||
}
|
||||
setBusy(null);
|
||||
};
|
||||
|
||||
const report = status.report as Report | null;
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div>
|
||||
<h2 className="flex items-center gap-2 text-lg font-semibold"><LogIn className="h-5 w-5 text-brand-600" aria-hidden /> Sign-in</h2>
|
||||
<p className="text-sm text-gray-600 mt-1">
|
||||
{status.mode === "accounts"
|
||||
? "People sign in with their church account, the same one they use for the church's other sites and apps. Passwords and two-step sign-in are managed there."
|
||||
: "People sign in with a Cross Events password. You can move sign-in to your church's Accounts, so one account works for all the church's sites and apps."}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{msg && <p className={`text-sm rounded-lg px-3 py-2 ${msg.ok ? "bg-green-50 text-green-800" : "bg-red-50 text-red-800"}`} role="status">{msg.text}</p>}
|
||||
|
||||
{status.mode === "accounts" ? (
|
||||
<section className="border rounded-xl p-4 space-y-3">
|
||||
<p className="text-sm"><span className="font-medium">Through Accounts</span>{status.accountsUrl ? <> at <a className="underline" href={status.accountsUrl} target="_blank" rel="noreferrer">{status.accountsUrl.replace(/^https?:\/\//, "")}</a></> : null}{status.movedAt ? `, since ${when(status.movedAt)}` : ""}.</p>
|
||||
{report && (
|
||||
<ul className="text-sm text-gray-700 list-disc pl-5 space-y-1">
|
||||
<li>{report.created} people moved{report.by ? ` (by ${report.by})` : ""}.</li>
|
||||
{report.linked.length > 0 && <li>{report.linked.length} already had an account and were linked to it: {report.linked.map((l) => l.email).join(", ")}.</li>}
|
||||
{report.refused.length > 0 && <li>{report.refused.length} couldn't move: {report.refused.map((r) => `${r.email} (${r.reason})`).join("; ")}.</li>}
|
||||
<li>{report.skipped} guests and deleted people stay in Cross Events only.</li>
|
||||
<li>Also Accounts admins: {report.accountsAdmins.map((a) => a.name).join(", ") || "nobody"}.</li>
|
||||
</ul>
|
||||
)}
|
||||
{status.undoUntil && !status.secretsCleared ? (
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
<button type="button" onClick={runUndo} disabled={!!busy} className="px-3 py-2 rounded-lg border text-sm">{busy === "undo" ? "Going back…" : "Undo the move"}</button>
|
||||
<span className="text-xs text-gray-500">Possible until {when(status.undoUntil)}. After that, Cross Events removes the old passwords.</span>
|
||||
</div>
|
||||
) : <p className="text-xs text-gray-500">Cross Events no longer holds anyone's password.</p>}
|
||||
</section>
|
||||
) : !status.accountsConnected ? (
|
||||
<section className="border rounded-xl p-4">
|
||||
<p className="text-sm text-gray-700">Connect your church's Accounts first, under <span className="font-medium">Linked products</span>. Ask Cross Code to install Accounts if it isn't listed there.</p>
|
||||
</section>
|
||||
) : (
|
||||
<section className="border rounded-xl p-4 space-y-4">
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
<button type="button" onClick={runCheck} disabled={!!busy || status.running} className="px-3 py-2 rounded-lg border text-sm">{busy === "check" ? "Checking…" : checked ? "Check again" : "Check the move"}</button>
|
||||
<span className="text-xs text-gray-500">Nothing changes until you press Move.</span>
|
||||
</div>
|
||||
{checked && (
|
||||
<div className="space-y-4">
|
||||
<ul className="text-sm text-gray-700 list-disc pl-5 space-y-1">
|
||||
<li>{checked.wouldCreate} people move with their current password{checked.withTwoFactor ? `; ${checked.withTwoFactor} use two-step sign-in and keep their method (they get new recovery codes the first time)` : ""}.</li>
|
||||
{checked.wouldLink.length > 0 && <li>{checked.wouldLink.length} already have a church account and will be linked to it (they keep that account's password): {checked.wouldLink.map((l) => l.email).join(", ")}.</li>}
|
||||
{checked.refused.length > 0 && <li className="text-red-700">{checked.refused.length} can't move: {checked.refused.map((r) => `${r.email} (${r.reason})`).join("; ")}. Fix these first, or they won't be able to sign in.</li>}
|
||||
<li>{checked.skipped} guests and deleted people stay in Cross Events only.</li>
|
||||
<li>Accounts {checked.accountsVersion}.</li>
|
||||
</ul>
|
||||
{checked.admins.length > 0 && (
|
||||
<fieldset>
|
||||
<legend className="text-sm font-medium mb-1">Also make these admins Accounts admins (they can manage everyone's sign-in)</legend>
|
||||
{checked.admins.map((a) => (
|
||||
<label key={a.id} className="flex items-center gap-2 text-sm py-0.5">
|
||||
<input type="checkbox" checked={admins.has(a.id)} onChange={(e) => {
|
||||
const next = new Set(admins);
|
||||
if (e.target.checked) next.add(a.id); else next.delete(a.id);
|
||||
setAdmins(next);
|
||||
}} />
|
||||
{a.name} <span className="text-gray-500">({a.email})</span>
|
||||
</label>
|
||||
))}
|
||||
</fieldset>
|
||||
)}
|
||||
{checked.noticeConflict && (
|
||||
<fieldset>
|
||||
<legend className="text-sm font-medium mb-1">Accounts already has its own privacy notice. Which one should people see?</legend>
|
||||
<label className="flex items-center gap-2 text-sm py-0.5"><input type="radio" name="notice" checked={keepAccountsNotices} onChange={() => setKeepAccountsNotices(true)} /> Keep Accounts' notice (everyone accepts it at their next sign-in)</label>
|
||||
<label className="flex items-center gap-2 text-sm py-0.5 text-gray-400"><input type="radio" name="notice" disabled checked={!keepAccountsNotices} readOnly /> Use Cross Events' notice (remove Accounts' notice in Accounts first)</label>
|
||||
</fieldset>
|
||||
)}
|
||||
<button type="button" onClick={runMove} disabled={!!busy || (!!checked.noticeConflict && !keepAccountsNotices)} className="px-4 py-2 rounded-lg bg-brand-600 text-white text-sm font-medium disabled:opacity-50">
|
||||
{busy === "move" ? "Moving… (don't close this page)" : "Move sign-in to Accounts"}
|
||||
</button>
|
||||
<p className="text-xs text-gray-500">Pick a quiet time. It takes about a minute; people already signed in stay signed in. You can undo it for 14 days.</p>
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
"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<AuthMode | null>(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 <div className="min-h-[50vh] flex items-center justify-center text-sm text-gray-500" role="status">Loading…</div>;
|
||||
}
|
||||
if (mode === "accounts") return <SignInMoved kind={kind} />;
|
||||
return <>{children}</>;
|
||||
}
|
||||
|
||||
function SignInMoved({ kind }: { kind: Kind }) {
|
||||
return (
|
||||
<div className="min-h-[60vh] flex items-center justify-center p-6">
|
||||
<div className="w-full max-w-md border rounded-2xl p-8 bg-white shadow-sm">
|
||||
<h1 className="text-xl font-semibold text-gray-900 mb-2">Sign-in has moved</h1>
|
||||
<p className="text-sm text-gray-600 mb-6">
|
||||
{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."}
|
||||
</p>
|
||||
<a href={signInHref("/dashboard")} className="inline-block w-full text-center px-4 py-2.5 rounded-lg bg-brand-600 text-white text-sm font-medium">Sign in</a>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { fetchAuthInfo, type AuthInfo } from "@/lib/signIn";
|
||||
|
||||
/** Whether sign-in goes through the church's Accounts (3.0.0), and its account page; null while loading. */
|
||||
export function useAuthInfo(): AuthInfo | null {
|
||||
const [info, setInfo] = useState<AuthInfo | null>(null);
|
||||
useEffect(() => {
|
||||
let alive = true;
|
||||
fetchAuthInfo().then((i) => { if (alive) setInfo(i); });
|
||||
return () => { alive = false; };
|
||||
}, []);
|
||||
return info;
|
||||
}
|
||||
|
||||
/** "Your sign-in and security are on your church account", with a link to it. */
|
||||
export function ChurchAccountNotice({ accountUrl, what }: { accountUrl: string | null; what: string }) {
|
||||
return (
|
||||
<section className="border rounded-xl p-5 bg-white shadow-sm">
|
||||
<h2 className="text-lg font-semibold text-gray-900 mb-2">On your church account</h2>
|
||||
<p className="text-sm text-gray-600 mb-4">{what}</p>
|
||||
{accountUrl && (
|
||||
<a href={accountUrl} className="inline-block px-4 py-2 rounded-lg bg-brand-600 text-white text-sm font-medium hover:bg-brand-700">Open my church account</a>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import React, { createContext, useCallback, useContext, useEffect, useMemo, useS
|
||||
import { ApiError } from "@/lib/api";
|
||||
import { AuthResponse, AuthUser, TwoFactorChallenge, clearToken, getDeviceToken, getToken, saveDeviceToken, saveToken } from "@/lib/auth";
|
||||
import { apiV2, type V2Result, apiV2Data } from "@/lib/apiV2";
|
||||
import { API_BASE } from "@/lib/api";
|
||||
import { fetchAuthMode } from "@/lib/signIn";
|
||||
|
||||
// A v2 "signed_in" answer as the session the app keeps (the user's fields plus the token).
|
||||
type V2Session = Extract<V2Result<"/auth/login", "post">["data"], { status: "signed_in" }>;
|
||||
@@ -142,10 +144,21 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
}, []);
|
||||
|
||||
const logout = useCallback(() => {
|
||||
const t = getToken();
|
||||
clearToken();
|
||||
cacheUser(null);
|
||||
setToken(null);
|
||||
setUser(null);
|
||||
// 3.0.0: signed in through the church's Accounts, signing out here signs out there too (and of
|
||||
// the church's other products), then comes back to this site's home page.
|
||||
if (t) {
|
||||
fetchAuthMode()
|
||||
.then((m) => (m === "accounts"
|
||||
? fetch(`${API_BASE}/api/auth/signout`, { method: "POST", headers: { Authorization: `Bearer ${t}`, "Content-Type": "application/json" }, body: "{}" }).then((r) => r.json())
|
||||
: null))
|
||||
.then((j: { data?: { url?: string | null } } | null) => { if (j?.data?.url) window.location.assign(j.data.url); })
|
||||
.catch(() => { /* signed out here either way */ });
|
||||
}
|
||||
}, []);
|
||||
|
||||
// Some endpoints (profile update, password change, session revocation) issue a
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import { useEffect } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
import { currentPage } from "@/lib/signIn";
|
||||
|
||||
/**
|
||||
* Use inside any client component that requires authentication.
|
||||
@@ -19,7 +20,9 @@ export function useRequireAuth(redirectTo = "/login") {
|
||||
|
||||
useEffect(() => {
|
||||
if (loading) return;
|
||||
if (!user) router.replace(redirectTo);
|
||||
// Back to this exact page after signing in (3.0.0: through the church's Accounts, which
|
||||
// `/login` forwards to).
|
||||
if (!user) router.replace(redirectTo === "/login" ? `/login?redirect=${encodeURIComponent(currentPage())}` : redirectTo);
|
||||
}, [user, loading, router, redirectTo]);
|
||||
|
||||
const ready = !loading && !!user;
|
||||
|
||||
@@ -72240,6 +72240,950 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/auth/mode": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Accounts"
|
||||
],
|
||||
"summary": "Where people sign in",
|
||||
"description": "`accounts`: send people to `GET /api/auth/signin?returnTo=<this page>` (the church's Accounts). `local`: Cross Events' own sign-in.\n\n**Who:** Anyone.",
|
||||
"operationId": "getAuthMode",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"mode": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"local",
|
||||
"accounts"
|
||||
]
|
||||
},
|
||||
"signInUrl": {
|
||||
"type": "string"
|
||||
},
|
||||
"accountUrl": {
|
||||
"description": "With `accounts`: the church account page (profile, password, two-step sign-in, privacy)",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"mode",
|
||||
"signInUrl",
|
||||
"accountUrl"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"data"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/settings/sign-in": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Accounts"
|
||||
],
|
||||
"summary": "Sign-in: where it is and the move to Accounts",
|
||||
"description": "**Who:** Admins only.",
|
||||
"operationId": "getSettingsSign-in",
|
||||
"security": [
|
||||
{
|
||||
"bearerAuth": []
|
||||
}
|
||||
],
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"mode": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"local",
|
||||
"accounts"
|
||||
],
|
||||
"description": "local: Cross Events' own sign-in; accounts: through the church's Accounts"
|
||||
},
|
||||
"accountsConnected": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"accountsUrl": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"movedAt": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"undoUntil": {
|
||||
"description": "Undo is possible until then (14 days after the move)",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"secretsCleared": {
|
||||
"type": "boolean",
|
||||
"description": "The old passwords have been removed (Undo is no longer possible)"
|
||||
},
|
||||
"running": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"report": {
|
||||
"anyOf": [
|
||||
{},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"mode",
|
||||
"accountsConnected",
|
||||
"accountsUrl",
|
||||
"movedAt",
|
||||
"undoUntil",
|
||||
"secretsCleared",
|
||||
"running",
|
||||
"report"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"data"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Not signed in (UNAUTHENTICATED)",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "Not allowed for this role (FORBIDDEN)",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/settings/sign-in/check": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"Accounts"
|
||||
],
|
||||
"summary": "Check the move to Accounts (nothing changes)",
|
||||
"description": "Who would move, who already has an account (they're linked to it), who is skipped (guests, deleted) and anything that would stop the move.\n\n**Who:** Admins only.",
|
||||
"operationId": "postSettingsSign-inCheck",
|
||||
"security": [
|
||||
{
|
||||
"bearerAuth": []
|
||||
}
|
||||
],
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"accountsVersion": {
|
||||
"type": "string"
|
||||
},
|
||||
"toMove": {
|
||||
"type": "integer",
|
||||
"minimum": -9007199254740991,
|
||||
"maximum": 9007199254740991
|
||||
},
|
||||
"wouldCreate": {
|
||||
"type": "integer",
|
||||
"minimum": -9007199254740991,
|
||||
"maximum": 9007199254740991
|
||||
},
|
||||
"wouldLink": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"email": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name",
|
||||
"email"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"refused": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"email": {
|
||||
"type": "string"
|
||||
},
|
||||
"reason": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name",
|
||||
"email",
|
||||
"reason"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"skipped": {
|
||||
"type": "integer",
|
||||
"minimum": -9007199254740991,
|
||||
"maximum": 9007199254740991
|
||||
},
|
||||
"admins": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"email": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name",
|
||||
"email",
|
||||
"id"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"noticeConflict": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"accountsVersions": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"eventsVersions": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"accountsVersions",
|
||||
"eventsVersions"
|
||||
],
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
},
|
||||
"withTwoFactor": {
|
||||
"type": "integer",
|
||||
"minimum": -9007199254740991,
|
||||
"maximum": 9007199254740991
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"accountsVersion",
|
||||
"toMove",
|
||||
"wouldCreate",
|
||||
"wouldLink",
|
||||
"refused",
|
||||
"skipped",
|
||||
"admins",
|
||||
"noticeConflict",
|
||||
"withTwoFactor"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"data"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Not signed in (UNAUTHENTICATED)",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "Not allowed for this role (FORBIDDEN)",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/settings/sign-in/move": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"Accounts"
|
||||
],
|
||||
"summary": "Move sign-in to Accounts",
|
||||
"description": "Copies everyone into the church's Accounts with their passwords and authenticator apps, checks the count, then switches. Nothing switches if anything fails, and it can be run again. Undo for 14 days.\n\n**Who:** Admins only.",
|
||||
"operationId": "postSettingsSign-inMove",
|
||||
"security": [
|
||||
{
|
||||
"bearerAuth": []
|
||||
}
|
||||
],
|
||||
"parameters": [],
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"adminIds": {
|
||||
"maxItems": 500,
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"format": "uuid",
|
||||
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
|
||||
},
|
||||
"description": "Events admins who also become Accounts admins"
|
||||
},
|
||||
"keepAccountsNotices": {
|
||||
"description": "When Accounts has its own privacy notice: keep it (everyone accepts it at their next sign-in) instead of Events'",
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"adminIds"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"mode": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"local",
|
||||
"accounts"
|
||||
],
|
||||
"description": "local: Cross Events' own sign-in; accounts: through the church's Accounts"
|
||||
},
|
||||
"accountsConnected": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"accountsUrl": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"movedAt": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"undoUntil": {
|
||||
"description": "Undo is possible until then (14 days after the move)",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"secretsCleared": {
|
||||
"type": "boolean",
|
||||
"description": "The old passwords have been removed (Undo is no longer possible)"
|
||||
},
|
||||
"running": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"report": {
|
||||
"anyOf": [
|
||||
{},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"mode",
|
||||
"accountsConnected",
|
||||
"accountsUrl",
|
||||
"movedAt",
|
||||
"undoUntil",
|
||||
"secretsCleared",
|
||||
"running",
|
||||
"report"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"data"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Validation failed (VALIDATION_FAILED)",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Not signed in (UNAUTHENTICATED)",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "Not allowed for this role (FORBIDDEN)",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/settings/sign-in/undo": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"Accounts"
|
||||
],
|
||||
"summary": "Undo the move (back to Cross Events' own sign-in)",
|
||||
"description": "Within 14 days of the move. People sign in with the password they had at the move; changes made in Accounts since then don't come back here.\n\n**Who:** Admins only.",
|
||||
"operationId": "postSettingsSign-inUndo",
|
||||
"security": [
|
||||
{
|
||||
"bearerAuth": []
|
||||
}
|
||||
],
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"mode": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"local",
|
||||
"accounts"
|
||||
],
|
||||
"description": "local: Cross Events' own sign-in; accounts: through the church's Accounts"
|
||||
},
|
||||
"accountsConnected": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"accountsUrl": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"movedAt": {
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"undoUntil": {
|
||||
"description": "Undo is possible until then (14 days after the move)",
|
||||
"type": [
|
||||
"string",
|
||||
"null"
|
||||
]
|
||||
},
|
||||
"secretsCleared": {
|
||||
"type": "boolean",
|
||||
"description": "The old passwords have been removed (Undo is no longer possible)"
|
||||
},
|
||||
"running": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"report": {
|
||||
"anyOf": [
|
||||
{},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"mode",
|
||||
"accountsConnected",
|
||||
"accountsUrl",
|
||||
"movedAt",
|
||||
"undoUntil",
|
||||
"secretsCleared",
|
||||
"running",
|
||||
"report"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"data"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Not signed in (UNAUTHENTICATED)",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "Not allowed for this role (FORBIDDEN)",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/users/{id}/account/reset-two-factor": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"Accounts"
|
||||
],
|
||||
"summary": "Reset someone's two-step sign-in (in Accounts)",
|
||||
"description": "They set it up again at their next sign-in, and are signed out everywhere.\n\n**Who:** Admins only.",
|
||||
"operationId": "postUsersIdAccountReset-two-factor",
|
||||
"security": [
|
||||
{
|
||||
"bearerAuth": []
|
||||
}
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"description": "The id",
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"format": "uuid",
|
||||
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"ok": {
|
||||
"type": "boolean",
|
||||
"const": true
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"ok"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"data"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Validation failed (VALIDATION_FAILED)",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Not signed in (UNAUTHENTICATED)",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "Not allowed for this role (FORBIDDEN)",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Not found (NOT_FOUND)",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/users/{id}/account/unlock": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"Accounts"
|
||||
],
|
||||
"summary": "Unlock someone after too many wrong passwords (in Accounts)",
|
||||
"description": "**Who:** Admins only.",
|
||||
"operationId": "postUsersIdAccountUnlock",
|
||||
"security": [
|
||||
{
|
||||
"bearerAuth": []
|
||||
}
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"description": "The id",
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"format": "uuid",
|
||||
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"ok": {
|
||||
"type": "boolean",
|
||||
"const": true
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"ok"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"data"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Validation failed (VALIDATION_FAILED)",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Not signed in (UNAUTHENTICATED)",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "Not allowed for this role (FORBIDDEN)",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Not found (NOT_FOUND)",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/users/{id}/account/active": {
|
||||
"post": {
|
||||
"tags": [
|
||||
"Accounts"
|
||||
],
|
||||
"summary": "Turn someone's church account off or on everywhere (in Accounts)",
|
||||
"description": "Off signs them out of every product of the church. To only stop them using Cross Events, deactivate them here instead.\n\n**Who:** Admins only.",
|
||||
"operationId": "postUsersIdAccountActive",
|
||||
"security": [
|
||||
{
|
||||
"bearerAuth": []
|
||||
}
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true,
|
||||
"description": "The id",
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"format": "uuid",
|
||||
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
|
||||
}
|
||||
}
|
||||
],
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"active": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"active"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"ok": {
|
||||
"type": "boolean",
|
||||
"const": true
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"ok"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"data"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Validation failed (VALIDATION_FAILED)",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Not signed in (UNAUTHENTICATED)",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "Not allowed for this role (FORBIDDEN)",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Not found (NOT_FOUND)",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
|
||||
+645
@@ -7498,6 +7498,178 @@ export interface paths {
|
||||
patch?: never;
|
||||
trace?: never;
|
||||
};
|
||||
"/auth/mode": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path?: never;
|
||||
cookie?: never;
|
||||
};
|
||||
/**
|
||||
* Where people sign in
|
||||
* @description `accounts`: send people to `GET /api/auth/signin?returnTo=<this page>` (the church's Accounts). `local`: Cross Events' own sign-in.
|
||||
*
|
||||
* **Who:** Anyone.
|
||||
*/
|
||||
get: operations["getAuthMode"];
|
||||
put?: never;
|
||||
post?: never;
|
||||
delete?: never;
|
||||
options?: never;
|
||||
head?: never;
|
||||
patch?: never;
|
||||
trace?: never;
|
||||
};
|
||||
"/settings/sign-in": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path?: never;
|
||||
cookie?: never;
|
||||
};
|
||||
/**
|
||||
* Sign-in: where it is and the move to Accounts
|
||||
* @description **Who:** Admins only.
|
||||
*/
|
||||
get: operations["getSettingsSign-in"];
|
||||
put?: never;
|
||||
post?: never;
|
||||
delete?: never;
|
||||
options?: never;
|
||||
head?: never;
|
||||
patch?: never;
|
||||
trace?: never;
|
||||
};
|
||||
"/settings/sign-in/check": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path?: never;
|
||||
cookie?: never;
|
||||
};
|
||||
get?: never;
|
||||
put?: never;
|
||||
/**
|
||||
* Check the move to Accounts (nothing changes)
|
||||
* @description Who would move, who already has an account (they're linked to it), who is skipped (guests, deleted) and anything that would stop the move.
|
||||
*
|
||||
* **Who:** Admins only.
|
||||
*/
|
||||
post: operations["postSettingsSign-inCheck"];
|
||||
delete?: never;
|
||||
options?: never;
|
||||
head?: never;
|
||||
patch?: never;
|
||||
trace?: never;
|
||||
};
|
||||
"/settings/sign-in/move": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path?: never;
|
||||
cookie?: never;
|
||||
};
|
||||
get?: never;
|
||||
put?: never;
|
||||
/**
|
||||
* Move sign-in to Accounts
|
||||
* @description Copies everyone into the church's Accounts with their passwords and authenticator apps, checks the count, then switches. Nothing switches if anything fails, and it can be run again. Undo for 14 days.
|
||||
*
|
||||
* **Who:** Admins only.
|
||||
*/
|
||||
post: operations["postSettingsSign-inMove"];
|
||||
delete?: never;
|
||||
options?: never;
|
||||
head?: never;
|
||||
patch?: never;
|
||||
trace?: never;
|
||||
};
|
||||
"/settings/sign-in/undo": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path?: never;
|
||||
cookie?: never;
|
||||
};
|
||||
get?: never;
|
||||
put?: never;
|
||||
/**
|
||||
* Undo the move (back to Cross Events' own sign-in)
|
||||
* @description Within 14 days of the move. People sign in with the password they had at the move; changes made in Accounts since then don't come back here.
|
||||
*
|
||||
* **Who:** Admins only.
|
||||
*/
|
||||
post: operations["postSettingsSign-inUndo"];
|
||||
delete?: never;
|
||||
options?: never;
|
||||
head?: never;
|
||||
patch?: never;
|
||||
trace?: never;
|
||||
};
|
||||
"/users/{id}/account/reset-two-factor": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path?: never;
|
||||
cookie?: never;
|
||||
};
|
||||
get?: never;
|
||||
put?: never;
|
||||
/**
|
||||
* Reset someone's two-step sign-in (in Accounts)
|
||||
* @description They set it up again at their next sign-in, and are signed out everywhere.
|
||||
*
|
||||
* **Who:** Admins only.
|
||||
*/
|
||||
post: operations["postUsersIdAccountReset-two-factor"];
|
||||
delete?: never;
|
||||
options?: never;
|
||||
head?: never;
|
||||
patch?: never;
|
||||
trace?: never;
|
||||
};
|
||||
"/users/{id}/account/unlock": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path?: never;
|
||||
cookie?: never;
|
||||
};
|
||||
get?: never;
|
||||
put?: never;
|
||||
/**
|
||||
* Unlock someone after too many wrong passwords (in Accounts)
|
||||
* @description **Who:** Admins only.
|
||||
*/
|
||||
post: operations["postUsersIdAccountUnlock"];
|
||||
delete?: never;
|
||||
options?: never;
|
||||
head?: never;
|
||||
patch?: never;
|
||||
trace?: never;
|
||||
};
|
||||
"/users/{id}/account/active": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path?: never;
|
||||
cookie?: never;
|
||||
};
|
||||
get?: never;
|
||||
put?: never;
|
||||
/**
|
||||
* Turn someone's church account off or on everywhere (in Accounts)
|
||||
* @description Off signs them out of every product of the church. To only stop them using Cross Events, deactivate them here instead.
|
||||
*
|
||||
* **Who:** Admins only.
|
||||
*/
|
||||
post: operations["postUsersIdAccountActive"];
|
||||
delete?: never;
|
||||
options?: never;
|
||||
head?: never;
|
||||
patch?: never;
|
||||
trace?: never;
|
||||
};
|
||||
}
|
||||
export type webhooks = Record<string, never>;
|
||||
export interface components {
|
||||
@@ -39597,4 +39769,477 @@ export interface operations {
|
||||
};
|
||||
};
|
||||
};
|
||||
getAuthMode: {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path?: never;
|
||||
cookie?: never;
|
||||
};
|
||||
requestBody?: never;
|
||||
responses: {
|
||||
/** @description OK */
|
||||
200: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": {
|
||||
data: {
|
||||
/** @enum {string} */
|
||||
mode: "local" | "accounts";
|
||||
signInUrl: string;
|
||||
/** @description With `accounts`: the church account page (profile, password, two-step sign-in, privacy) */
|
||||
accountUrl: string | null;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
"getSettingsSign-in": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path?: never;
|
||||
cookie?: never;
|
||||
};
|
||||
requestBody?: never;
|
||||
responses: {
|
||||
/** @description OK */
|
||||
200: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": {
|
||||
data: {
|
||||
/**
|
||||
* @description local: Cross Events' own sign-in; accounts: through the church's Accounts
|
||||
* @enum {string}
|
||||
*/
|
||||
mode: "local" | "accounts";
|
||||
accountsConnected: boolean;
|
||||
accountsUrl: string | null;
|
||||
movedAt: string | null;
|
||||
/** @description Undo is possible until then (14 days after the move) */
|
||||
undoUntil: string | null;
|
||||
/** @description The old passwords have been removed (Undo is no longer possible) */
|
||||
secretsCleared: boolean;
|
||||
running: boolean;
|
||||
report: unknown | null;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
/** @description Not signed in (UNAUTHENTICATED) */
|
||||
401: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["Error"];
|
||||
};
|
||||
};
|
||||
/** @description Not allowed for this role (FORBIDDEN) */
|
||||
403: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["Error"];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
"postSettingsSign-inCheck": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path?: never;
|
||||
cookie?: never;
|
||||
};
|
||||
requestBody?: never;
|
||||
responses: {
|
||||
/** @description OK */
|
||||
200: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": {
|
||||
data: {
|
||||
accountsVersion: string;
|
||||
toMove: number;
|
||||
wouldCreate: number;
|
||||
wouldLink: {
|
||||
name: string;
|
||||
email: string;
|
||||
}[];
|
||||
refused: {
|
||||
name: string;
|
||||
email: string;
|
||||
reason: string;
|
||||
}[];
|
||||
skipped: number;
|
||||
admins: {
|
||||
name: string;
|
||||
email: string;
|
||||
id: string;
|
||||
}[];
|
||||
noticeConflict: {
|
||||
accountsVersions: number[];
|
||||
eventsVersions: number[];
|
||||
} | null;
|
||||
withTwoFactor: number;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
/** @description Not signed in (UNAUTHENTICATED) */
|
||||
401: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["Error"];
|
||||
};
|
||||
};
|
||||
/** @description Not allowed for this role (FORBIDDEN) */
|
||||
403: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["Error"];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
"postSettingsSign-inMove": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path?: never;
|
||||
cookie?: never;
|
||||
};
|
||||
requestBody: {
|
||||
content: {
|
||||
"application/json": {
|
||||
/** @description Events admins who also become Accounts admins */
|
||||
adminIds: string[];
|
||||
/** @description When Accounts has its own privacy notice: keep it (everyone accepts it at their next sign-in) instead of Events' */
|
||||
keepAccountsNotices?: boolean;
|
||||
};
|
||||
};
|
||||
};
|
||||
responses: {
|
||||
/** @description OK */
|
||||
200: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": {
|
||||
data: {
|
||||
/**
|
||||
* @description local: Cross Events' own sign-in; accounts: through the church's Accounts
|
||||
* @enum {string}
|
||||
*/
|
||||
mode: "local" | "accounts";
|
||||
accountsConnected: boolean;
|
||||
accountsUrl: string | null;
|
||||
movedAt: string | null;
|
||||
/** @description Undo is possible until then (14 days after the move) */
|
||||
undoUntil: string | null;
|
||||
/** @description The old passwords have been removed (Undo is no longer possible) */
|
||||
secretsCleared: boolean;
|
||||
running: boolean;
|
||||
report: unknown | null;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
/** @description Validation failed (VALIDATION_FAILED) */
|
||||
400: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["Error"];
|
||||
};
|
||||
};
|
||||
/** @description Not signed in (UNAUTHENTICATED) */
|
||||
401: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["Error"];
|
||||
};
|
||||
};
|
||||
/** @description Not allowed for this role (FORBIDDEN) */
|
||||
403: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["Error"];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
"postSettingsSign-inUndo": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path?: never;
|
||||
cookie?: never;
|
||||
};
|
||||
requestBody?: never;
|
||||
responses: {
|
||||
/** @description OK */
|
||||
200: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": {
|
||||
data: {
|
||||
/**
|
||||
* @description local: Cross Events' own sign-in; accounts: through the church's Accounts
|
||||
* @enum {string}
|
||||
*/
|
||||
mode: "local" | "accounts";
|
||||
accountsConnected: boolean;
|
||||
accountsUrl: string | null;
|
||||
movedAt: string | null;
|
||||
/** @description Undo is possible until then (14 days after the move) */
|
||||
undoUntil: string | null;
|
||||
/** @description The old passwords have been removed (Undo is no longer possible) */
|
||||
secretsCleared: boolean;
|
||||
running: boolean;
|
||||
report: unknown | null;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
/** @description Not signed in (UNAUTHENTICATED) */
|
||||
401: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["Error"];
|
||||
};
|
||||
};
|
||||
/** @description Not allowed for this role (FORBIDDEN) */
|
||||
403: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["Error"];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
"postUsersIdAccountReset-two-factor": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path: {
|
||||
/** @description The id */
|
||||
id: string;
|
||||
};
|
||||
cookie?: never;
|
||||
};
|
||||
requestBody?: never;
|
||||
responses: {
|
||||
/** @description OK */
|
||||
200: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": {
|
||||
data: {
|
||||
/** @constant */
|
||||
ok: true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
/** @description Validation failed (VALIDATION_FAILED) */
|
||||
400: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["Error"];
|
||||
};
|
||||
};
|
||||
/** @description Not signed in (UNAUTHENTICATED) */
|
||||
401: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["Error"];
|
||||
};
|
||||
};
|
||||
/** @description Not allowed for this role (FORBIDDEN) */
|
||||
403: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["Error"];
|
||||
};
|
||||
};
|
||||
/** @description Not found (NOT_FOUND) */
|
||||
404: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["Error"];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
postUsersIdAccountUnlock: {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path: {
|
||||
/** @description The id */
|
||||
id: string;
|
||||
};
|
||||
cookie?: never;
|
||||
};
|
||||
requestBody?: never;
|
||||
responses: {
|
||||
/** @description OK */
|
||||
200: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": {
|
||||
data: {
|
||||
/** @constant */
|
||||
ok: true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
/** @description Validation failed (VALIDATION_FAILED) */
|
||||
400: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["Error"];
|
||||
};
|
||||
};
|
||||
/** @description Not signed in (UNAUTHENTICATED) */
|
||||
401: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["Error"];
|
||||
};
|
||||
};
|
||||
/** @description Not allowed for this role (FORBIDDEN) */
|
||||
403: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["Error"];
|
||||
};
|
||||
};
|
||||
/** @description Not found (NOT_FOUND) */
|
||||
404: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["Error"];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
postUsersIdAccountActive: {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path: {
|
||||
/** @description The id */
|
||||
id: string;
|
||||
};
|
||||
cookie?: never;
|
||||
};
|
||||
requestBody: {
|
||||
content: {
|
||||
"application/json": {
|
||||
active: boolean;
|
||||
};
|
||||
};
|
||||
};
|
||||
responses: {
|
||||
/** @description OK */
|
||||
200: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": {
|
||||
data: {
|
||||
/** @constant */
|
||||
ok: true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
/** @description Validation failed (VALIDATION_FAILED) */
|
||||
400: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["Error"];
|
||||
};
|
||||
};
|
||||
/** @description Not signed in (UNAUTHENTICATED) */
|
||||
401: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["Error"];
|
||||
};
|
||||
};
|
||||
/** @description Not allowed for this role (FORBIDDEN) */
|
||||
403: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["Error"];
|
||||
};
|
||||
};
|
||||
/** @description Not found (NOT_FOUND) */
|
||||
404: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["Error"];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* Signing in through the church's Accounts (3.0.0, docs/EVENTS-3.0-PLAN.md §3). Once an admin has
|
||||
* moved sign-in (Settings → Sign-in), `/login`, `/register` and `/forgot-password` forward to
|
||||
* `GET /api/auth/signin?returnTo=…`, which sends the browser to Accounts and back to the same page.
|
||||
* Every existing `/login?redirect=…` link keeps working that way.
|
||||
*/
|
||||
import { API_BASE } from "@/lib/api";
|
||||
|
||||
export type AuthMode = "local" | "accounts";
|
||||
|
||||
export type AuthInfo = { mode: AuthMode; accountUrl: string | null };
|
||||
|
||||
let infoPromise: Promise<AuthInfo> | null = null;
|
||||
|
||||
/**
|
||||
* Where people sign in, and (through Accounts) the church account page, asked once per page load
|
||||
* (it only changes when an admin moves sign-in).
|
||||
*/
|
||||
export function fetchAuthInfo(): Promise<AuthInfo> {
|
||||
if (!infoPromise) {
|
||||
infoPromise = fetch(`${API_BASE}/api/v2/auth/mode`, { headers: { Accept: "application/json" } })
|
||||
.then((r) => (r.ok ? r.json() : null))
|
||||
.then((j: { data?: { mode?: AuthMode; accountUrl?: string | null } } | null): AuthInfo => ({
|
||||
mode: j?.data?.mode === "accounts" ? "accounts" : "local",
|
||||
accountUrl: j?.data?.accountUrl ?? null,
|
||||
}))
|
||||
.catch(() => {
|
||||
infoPromise = null;
|
||||
return { mode: "local" as const, accountUrl: null };
|
||||
});
|
||||
}
|
||||
return infoPromise;
|
||||
}
|
||||
|
||||
export function fetchAuthMode(): Promise<AuthMode> {
|
||||
return fetchAuthInfo().then((i) => i.mode);
|
||||
}
|
||||
|
||||
/** A relative path on this site, or the fallback: never another site (the backend checks too). */
|
||||
export function safePath(raw: string | null | undefined, fallback = "/dashboard"): string {
|
||||
const s = String(raw ?? "");
|
||||
return s.startsWith("/") && !s.startsWith("//") && !s.startsWith("/\\") ? s : fallback;
|
||||
}
|
||||
|
||||
/** The address that signs someone in through Accounts and brings them back to `returnTo`. */
|
||||
export function signInHref(returnTo: string, opts: { signUp?: boolean; email?: string } = {}): string {
|
||||
const q = new URLSearchParams({ returnTo: safePath(returnTo) });
|
||||
if (opts.signUp) q.set("signup", "1");
|
||||
if (opts.email) q.set("email", opts.email);
|
||||
return `${API_BASE}/api/auth/signin?${q.toString()}`;
|
||||
}
|
||||
|
||||
/** The page someone is on now (path and query), to come back to after signing in. */
|
||||
export function currentPage(): string {
|
||||
if (typeof window === "undefined") return "/";
|
||||
return `${window.location.pathname}${window.location.search}`;
|
||||
}
|
||||
Reference in New Issue
Block a user