Skip to content

Commit 9f6d95c

Browse files
yn1323claude
andcommitted
fix: マジックリンクトークンが既存セッション返却時に消費されない問題を修正
既存セッションを返す場合でもusedAtを設定し、トークンのワンタイム性を保証する。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d5a70cc commit 9f6d95c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

convex/staffAuth/mutations.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const verifyToken = mutation({
3838
};
3939
}
4040

41-
// 既存の有効なセッションがあればそれを返す(usedAtは設定しない)
41+
// 既存の有効なセッションがあればそれを返す
4242
const existingSessions = await ctx.db
4343
.query("sessions")
4444
.withIndex("by_staffId_recruitmentId", (q) =>
@@ -49,6 +49,7 @@ export const verifyToken = mutation({
4949
const validSession = existingSessions.find((s) => s.expiresAt > Date.now());
5050

5151
if (validSession) {
52+
await ctx.db.patch(magicLink._id, { usedAt: Date.now() });
5253
return {
5354
status: "ok" as const,
5455
sessionToken: validSession.sessionToken,

0 commit comments

Comments
 (0)