Skip to content

feat: implement Presentation layer for GET /api/v1/user/me / ログイン中ユーザー取得APIのPresentation層実装#543

Merged
zigzagdev merged 2 commits into
feat-user-me-apifrom
feat-user-me-api_presentation-layer
Jul 20, 2026
Merged

feat: implement Presentation layer for GET /api/v1/user/me / ログイン中ユーザー取得APIのPresentation層実装#543
zigzagdev merged 2 commits into
feat-user-me-apifrom
feat-user-me-api_presentation-layer

Conversation

@zigzagdev

Copy link
Copy Markdown
Owner

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 (#542). This was one of the causes preventing mypage from displaying.

Domain層・Infra層は既存の findById をそのまま利用でき、Application層も既存の GetUserByIdUseCase をそのまま流用できるため、変更が必要だったのはPresentation層のみ。

Domain and Infra layers already have findById implemented, and the Application layer can reuse the existing GetUserByIdUseCase as-is, so only the Presentation layer required changes.

Closes #542

What I have done / 実施内容

  • routes/api.phpGET /v1/user/meauth:sanctum ミドルウェア付きで追加
  • AuthController::me を追加し、$request->user()->id(Sanctumが認証セッション/トークンから解決した現在のユーザーのid)を既存の GetUserByIdUseCase に渡して結果を返す
  • 既存の UserViewModelFactory / UserViewModel をそのまま再利用してレスポンスを整形

Test Results / テスト結果

  • test_me_returns_200_with_authenticated_user_when_authenticated
  • test_me_returns_401_when_unauthenticated
  • test_me_returns_500_on_unexpected_error
  • 既存の LoginTest / LogoutTest も回帰なしを確認済み

@zigzagdev zigzagdev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.80519% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.51%. Comparing base (0ea56e1) to head (9489ee7).

Files with missing lines Patch % Lines
...pp/Packages/Features/Controller/AuthController.php 80.00% 4 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@                  Coverage Diff                   @@
##             feat-user-me-api     #543      +/-   ##
======================================================
+ 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     
Files with missing lines Coverage Δ
src/app/Packages/Features/Tests/MeTest.php 100.00% <100.00%> (ø)
...pp/Packages/Features/Controller/AuthController.php 93.22% <80.00%> (-6.78%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zigzagdev
zigzagdev merged commit 3af3152 into feat-user-me-api Jul 20, 2026
28 checks passed
@zigzagdev
zigzagdev deleted the feat-user-me-api_presentation-layer branch July 20, 2026 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Add GET /v1/user/me endpoint to fetch the authenticated user / ログイン中ユーザー自身の情報を取得するAPIの追加

1 participant