feat: add GET /api/v1/user/me endpoint / ログイン中ユーザー取得APIの追加#544
Merged
Conversation
…layer feat: implement Presentation layer for GET /api/v1/user/me / ログイン中ユーザー取得APIのPresentation層実装
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## feat/user #544 +/- ##
===============================================
+ Coverage 62.21% 62.51% +0.30%
- Complexity 1604 1615 +11
===============================================
Files 135 136 +1
Lines 8252 8329 +77
===============================================
+ Hits 5134 5207 +73
- Misses 3118 3122 +4
🚀 New features to boost your workflow:
|
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.
Motivation / 目的
AuthController::loginのレスポンスはトークンのみでユーザーのidを返さないため、フロントエンドはログイン後に「自分自身」の情報を取得する手段を持っていなかった。これがマイページ表示ができない一因だった (#542)。The login response only returns a token, never the user's id, so the frontend had no way to fetch "its own" user data after logging in. This was one of the causes preventing mypage from displaying (#542).
Closes #542
What I have done / 実施内容
routes/api.phpにGET /v1/user/meをauth:sanctumミドルウェア付きで追加AuthController::meを追加し、Sanctumが認証済みリクエストから解決したユーザーのidを既存のGetUserByIdUseCaseに渡して結果を返すfindByIdを、Application層は既存のGetUserByIdUseCaseをそのまま再利用(変更なし)。今回の変更はPresentation層のみ (feat: implement Presentation layer for GET /api/v1/user/me / ログイン中ユーザー取得APIのPresentation層実装 #543)Test Results / テスト結果
test_me_returns_200_with_authenticated_user_when_authenticatedtest_me_returns_401_when_unauthenticatedtest_me_returns_500_on_unexpected_errorLoginTest/LogoutTestの回帰なしを確認済み