Skip to content

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

Description

@zigzagdev

Motivation / 目的

While investigating #540 (mypage does not display after login), we found that the login response (AuthTokenDto) only returns token and token_type — it never returns the user's id. The only existing user-lookup endpoint is GET /v1/users/{id}, which requires the frontend to already know the target id. Since the frontend never learns its own id from the login response, mypage has no way to fetch "my own" user data.

We need a session-based endpoint that resolves the caller's identity from the authenticated Sanctum session, instead of requiring an id in the request.

What needs to be done / 実施内容

  • Domain layer: no change needed — UserRepositroyInterface::findById already exists
  • Infra layer: no change needed — UserRepository::findById is already implemented
  • Application layer: no change needed — reuse the existing GetUserByIdUseCase, passing the id resolved from the authenticated request ($request->user()->id) instead of a route parameter
  • Presentation layer:
    • Add route GET /v1/user/me protected by the auth:sanctum middleware
    • Add a controller method that resolves the authenticated user's id and calls GetUserByIdUseCase, returning the result via the existing UserViewModelFactory

Test Results / テスト結果

(to be filled in the corresponding PR)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions