// The address somebody has just signed up with, carried to sign-in for one visit. Held in memory, // not in the URL, so the address never lands in browser history. let handedEmail: { email: string; verified: boolean } | undefined; /** A patient who has just verified their address: sign-in says so. */ export const rememberVerifiedEmail = (email: string) => { handedEmail = { email, verified: true }; }; /** An address that only needs carrying, such as a just-created admin's: nothing was verified, so nothing says it was. */ export const rememberSignInEmail = (email: string) => { handedEmail = { email, verified: false }; }; /** Returns the handed address once, then forgets it, so a later visit to sign-in starts empty. */ export const takeSignInHandoff = (): { email: string; verified: boolean } => { const handed = handedEmail ?? { email: '', verified: false }; handedEmail = undefined; return handed; }; /** The address alone, for callers that only fill a field. */ export const takeVerifiedEmail = (): string => takeSignInHandoff().email;