fix(auth): atomically exchange gateway tokens

This commit is contained in:
Hide_D committed 2026-07-31 18:00:07 +00:00
1 parent 2596c47fc5
commit c29b40ba5a
4 files changed
+112 -21

No files matched your search

+2 -4
View File
@@ -87,15 +87,13 @@ export const authRouter = router({
await enqueueProfileIconResetForUser(ctx, payload.user.id, payload.user.profileIconResetAt);
}
const used = await ctx.accessTokenStore.markGatewayTokenUsed(payload.sessionId, ttlSeconds);
if (!used) {
const created = await ctx.accessTokenStore.issueFromGateway(payload);
if (created === 'ALREADY_USED') {
throw new TRPCError({
code: 'CONFLICT',
message: 'Gateway token already used.',
});
}
const created = await ctx.accessTokenStore.create(payload);
if (!created) {
throw new TRPCError({
code: 'INTERNAL_SERVER_ERROR',