確認コード画面に再送信と登録やり直しの導線を追加する - #13
Merged
Merged
Conversation
サインアップ後の /verify-otp から抜ける手段が正しいOTPの入力しかなく、 コードは1回しか送られないためメールの見逃し・期限切れ・メールアドレスの 打ち間違いで閉じ込められていた。 - 確認コードの再送信(60秒クールダウン)を追加 - 期限切れ・試行回数超過を個別のメッセージで案内し、その場合は クールダウンを解除して即再送信できるようにする - 送信先メールアドレスを強調表示し、誤りに気づけるようにする - 「別のメールアドレスで登録し直す」導線を追加(未認証アカウントは メールアドレスを変更できないため、サインアップからやり直す) - OTPの有効期限を10分・試行回数を3回として明示する Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
再送信のクールダウンがフロントのstateのみで、リロードすれば無制限に メールを送信できる状態だった。Better Authのレート制限で送信APIを 60秒に1回に制限し、フロントはX-Retry-Afterに従うようにする。 クールダウンは締切時刻をsessionStorageに保存し、リロードをまたいで復元する。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
サインアップ後に
/verify-otpへ飛ばされると、そこから抜ける手段が「正しい確認コードを入力すること」しかなかった。apps/api/src/routes/auth.ts)_app.tsx/select-site.tsx/login.tsxのガードがemailVerified === falseなら無条件に/verify-otpへ戻すそのため、メールの見逃し・期限切れ・メールアドレスの打ち間違いのいずれでも、ログインし直しても永久に確認画面に閉じ込められていた。
変更内容
emailOtp.sendVerificationOtp()を呼ぶだけOTP_EXPIRED/TOO_MANY_ATTEMPTSは専用メッセージを出し、そのコードはもう成功しえないためクールダウンを解除して即再送信できるようにした(それ以外は従来どおり「コードが正しくありません」)emailOTPにexpiresIn: 600(10分。自前のメール変更OTPと同じTTL)とallowedAttempts: 3を明示docs/domain/auth.mdに追記動作確認
ローカルAPI + mailpit に対して実行し、以下を確認済み。
TOO_MANY_ATTEMPTSが返るemailVerified: trueになりガードが解けるbiome check/tsc --noEmitは変更ファイルでクリーン。🤖 Generated with Claude Code