feat: Better Authでメール/パスワード認証を追加 - #36
Draft
tknkaa wants to merge 1 commit into
Draft
Conversation
- lib/auth.ts, lib/auth-client.ts, app/api/auth/[...all]/route.ts でBetter Authを導入 - proxy.ts(Next.js 16のmiddleware後継)で /my-notebooks 配下をログイン必須にし、 ログイン済みなら /login, /signup から追い出す楽観的チェックを追加 - lib/session.ts の requireUser() で各ページ・Server Action側の本チェックを実施 - ログイン/新規登録ページとヘッダーのログイン状態表示・ログアウトボタンを追加 - Prisma schemaに User/Session/Account/Verification を追加し、Notebook.userId を必須化。 単語帳の作成・閲覧・編集・削除をすべて所有者本人に限定 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lad52Pk8VQZpi7uFAmVDNA
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.
Summary
NotebookにuserIdを追加し、My単語帳をログインユーザーに紐付け。作成・閲覧・編集・削除はすべて所有者本人のみに限定proxy.ts(Next.js 16でmiddleware.tsから改名された規約)で/my-notebooks配下を未ログインなら/loginへリダイレクトする楽観的チェックを追加し、lib/session.tsのrequireUser()で各ページ・Server Action側の本チェックを実施開発環境向けの注意
prisma/schema.prismaにUser/Session/Account/Verificationテーブルを追加するマイグレーションを含みます。ローカルで取り込む際はprisma migrate devの実行と、既存のprisma/dev.dbのリセットが必要になる場合があります.envにBETTER_AUTH_SECRET(openssl rand -base64 32などで生成)とBETTER_AUTH_URLの設定が必要です(.env.example参照)Test plan
npm run typecheck/npm run lint/npm run formatが通ることを確認/my-notebooksへのアクセスを確認/my-notebooksが/loginへリダイレクトされることを確認/login,/signupにアクセスすると/my-notebooksへリダイレクトされることを確認🤖 Generated with Claude Code
https://claude.ai/code/session_01Lad52Pk8VQZpi7uFAmVDNA