Skip to content

Commit 9bb1e6a

Browse files
committed
test(auth): a proof spent after admission revokes no session at the one-step door
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5nNrLRm8ssuwWcBVcw
1 parent 2633dc1 commit 9bb1e6a

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

‎packages/plugins/plugin-auth/src/invitation-one-step-acceptance-34257.test.ts‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,6 +1146,29 @@ describe('#34257 — the door sets a password on an existing account only where
11461146
await expectAccepted(await door(manager, { invitationId: invitation.id, proof, name: 'R', password: NEW_PASSWORD }));
11471147
},
11481148
);
1149+
1150+
it('a proof spent by another redemption after this one was admitted revokes no session and writes no password', async () => {
1151+
const { engine, manager, invite } = await boot();
1152+
const email = 'raced-spent@example.com';
1153+
const { invitation, proof } = await invite(email);
1154+
const { userId, cookie } = await signUp(manager, engine, email);
1155+
const credential = () => (engine.tables.get('sys_account') ?? []).find((a) => a.user_id === userId && a.provider_id === 'credential');
1156+
const password = credential()!.password;
1157+
const find = engine.find.bind(engine);
1158+
engine.find = async (name: string, q: any = {}) => {
1159+
const rows = await find(name, q);
1160+
if (name === 'sys_api_key') {
1161+
const identifier = invitationProofIdentifier(invitation.id);
1162+
engine.tables.set('sys_verification', (engine.tables.get('sys_verification') ?? []).filter((v) => v.identifier !== identifier));
1163+
}
1164+
return rows;
1165+
};
1166+
1167+
await expectRefused(await door(manager, { invitationId: invitation.id, proof, name: 'R', password: NEW_PASSWORD }));
1168+
engine.find = find;
1169+
expect(credential()!.password).toBe(password);
1170+
expect(await sessionUser(manager, cookie)).not.toBeNull();
1171+
});
11491172
});
11501173

11511174
describe('#34257 — a password the door sets starts the password-age clock and clears a forced change', () => {

0 commit comments

Comments
 (0)