Skip to content

Commit 4d27b2c

Browse files
committed
fix(plugin-auth): keep the gate-verdict carrier beside the request record
Claude-Session: https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f Co-authored-by: Claude <noreply@anthropic.com>
1 parent c3b8994 commit 4d27b2c

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

‎packages/plugins/plugin-auth/src/sign-in-lockout-refusal.ts‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,30 @@ export async function readLockoutRequestState(): Promise<LockoutRequest | undefi
144144
}
145145
}
146146

147+
/**
148+
* Record the gate's verdict for the request that is running (`undefined`: this
149+
* attempt has none, whatever an earlier call recorded). `false` when no request
150+
* state is open, which the gate treats as "the verifier cannot carry the
151+
* refusal" and refuses by itself instead.
152+
*/
153+
export async function recordSignInAttempt(attempt: SignInAttempt | undefined): Promise<boolean> {
154+
try {
155+
await signInAttemptState.set(attempt);
156+
return true;
157+
} catch {
158+
return false;
159+
}
160+
}
161+
162+
/** The verdict the gate recorded for the request that is running, if any. Never throws. */
163+
export async function readSignInAttempt(): Promise<SignInAttempt | undefined> {
164+
try {
165+
return await signInAttemptState.get();
166+
} catch {
167+
return undefined;
168+
}
169+
}
170+
147171
/** better-auth's `emailAndPassword.password` pair. */
148172
export interface PasswordHasher {
149173
hash: (password: string) => Promise<string>;

0 commit comments

Comments
 (0)