Accounts 1.1.0: moving Events' users in, people.* requests, new recovery codes
POST /api/accounts/v1/requests (crosscode.identity-request/1): import.* keeps each person's Events id as sub, password hash and authenticator secret (sealed in transit), consent, notices and lockout; linked when the email already has an account. people.* for product admins, limited to people the product knows. New recovery codes after the first 2FA sign-in for people moved in with 2FA. screen=signup. auth-client: request(), seal(), signUp. 8 new tests (47 in all). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,7 @@ type State = {
|
||||
product: string;
|
||||
signupEnabled: boolean;
|
||||
loginHint?: string | null;
|
||||
screen?: "signin" | "signup";
|
||||
name?: string;
|
||||
email?: string;
|
||||
sentTo?: string;
|
||||
@@ -35,16 +36,29 @@ export function SignIn({ uid }: { uid: string }) {
|
||||
const [error, setError] = useState<ApiError | null>(null);
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [mode, setMode] = useState<"signin" | "signup">("signin");
|
||||
const [codes, setCodes] = useState<{ codes: string[]; next: string } | null>(null);
|
||||
const [codes, setCodes] = useState<{ codes: string[]; next: State } | null>(null);
|
||||
const [opened, setOpened] = useState(false);
|
||||
|
||||
const apply = (s: State) => {
|
||||
// New recovery codes (2FA just set up, or moved in from Cross Events without them) are shown
|
||||
// first, whatever comes next.
|
||||
const go = (s: State) => {
|
||||
if (s.stage === "done" && s.redirectTo) {
|
||||
if (s.recoveryCodes?.length) setCodes({ codes: s.recoveryCodes, next: s.redirectTo });
|
||||
else window.location.assign(s.redirectTo);
|
||||
window.location.assign(s.redirectTo);
|
||||
return;
|
||||
}
|
||||
setState(s);
|
||||
};
|
||||
const apply = (s: State) => {
|
||||
if (!opened) {
|
||||
setOpened(true);
|
||||
if (s.screen === "signup" && s.signupEnabled) setMode("signup");
|
||||
}
|
||||
if (s.recoveryCodes?.length) {
|
||||
setCodes({ codes: s.recoveryCodes, next: s });
|
||||
return;
|
||||
}
|
||||
go(s);
|
||||
};
|
||||
|
||||
useExternalEffect(() => {
|
||||
let alive = true;
|
||||
@@ -69,7 +83,7 @@ export function SignIn({ uid }: { uid: string }) {
|
||||
const frame = (children: React.ReactNode) => <Shell branding={branding}><Card>{children}</Card></Shell>;
|
||||
|
||||
if (codes) {
|
||||
return frame(<RecoveryCodes codes={codes.codes} onDone={() => window.location.assign(codes.next)} />);
|
||||
return frame(<RecoveryCodes codes={codes.codes} onDone={() => { const next = codes.next; setCodes(null); go(next); }} />);
|
||||
}
|
||||
if (!state) {
|
||||
return frame(error ? (
|
||||
|
||||
Reference in New Issue
Block a user