diff options
| author | yyamashita <yyamashita@hetzner.yyamashita.com> | 2026-06-19 23:57:00 +0900 |
|---|---|---|
| committer | yyamashita <yyamashita@hetzner.yyamashita.com> | 2026-06-19 23:57:00 +0900 |
| commit | 8ba6da44510355a4b1335c14c78fde3a0fd030fe (patch) | |
| tree | ce815c6a29baaec0ef6d22134e40972245c0ef9f /app | |
| parent | af1f23466c46bf4cebc42ab1687552b1a4baafd5 (diff) | |
Fix passkey registration: fixed userID + surface actual error message
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'app')
| -rw-r--r-- | app/routes/auth.register.tsx | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/app/routes/auth.register.tsx b/app/routes/auth.register.tsx index c064eff..01b0699 100644 --- a/app/routes/auth.register.tsx +++ b/app/routes/auth.register.tsx @@ -32,6 +32,7 @@ export async function action({ request }: Route.ActionArgs) { const options = await generateRegistrationOptions({ rpName, rpID, + userID: new Uint8Array([109, 105, 99, 114, 111, 98, 108, 111, 103]), // "microblog" userName: "admin", attestationType: "none", authenticatorSelection: { @@ -50,12 +51,19 @@ export async function action({ request }: Route.ActionArgs) { if (!challenge) return Response.json({ error: "セッション切れです" }, { status: 400 }); const body = (await request.json()) as RegistrationResponseJSON; - const verification = await verifyRegistrationResponse({ - response: body, - expectedChallenge: challenge, - expectedOrigin: origin, - expectedRPID: rpID, - }); + let verification; + try { + verification = await verifyRegistrationResponse({ + response: body, + expectedChallenge: challenge, + expectedOrigin: origin, + expectedRPID: rpID, + }); + } catch (err) { + const msg = err instanceof Error ? err.message : String(err); + console.error("[passkey] verifyRegistrationResponse failed:", msg); + return Response.json({ error: msg }, { status: 400 }); + } if (!verification.verified || !verification.registrationInfo) { return Response.json({ error: "登録に失敗しました" }, { status: 400 }); |
