feat: implement Login API across all layers / ユーザーログインAPIの全層実装#535
Merged
Conversation
…mail VO introduction
…ind-mail feat: implement Email ValueObject and findByEmail in Infra layer / Email ValueObjectとfindByEmailのInfra層実装
…ken-service feat: implement SanctumTokenService for token issuance and revocation / Sanctumトークン発行・失効のInfra層実装
… LoginUseCaseTest
feat: implement Application layer for User Login / ユーザーログインのApplication層実装
- Narrow source path to app/Packages only - Disable false-positive rules: no-literal-password, no-empty, no-nested-ternary, prefer-first-class-callable, block-statement, class-name - Raise cyclomatic-complexity threshold to 60, excessive-parameter-list to 25, too-many-methods to 30
…ayer feat: implement Presentation layer for User Login and introduce mago lint / ユーザーログインのPresentation層実装とmago lint導入
This was
linked to
issues
Jul 14, 2026
Closed
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## feat/user #535 +/- ##
===============================================
+ Coverage 60.30% 61.75% +1.45%
- Complexity 1534 1585 +51
===============================================
Files 123 132 +9
Lines 7854 8153 +299
===============================================
+ Hits 4736 5035 +299
Misses 3118 3118
🚀 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 / 目的
Implement
POST /api/v1/user/loginAPI using Laravel Sanctum for token-based authentication.Each layer was developed on its own branch and merged in sequence.
ユーザーログイン機能(
POST /api/v1/user/login)を実装しました。Laravel Sanctum を用いたトークン認証を採用し、DDD の各層を個別ブランチで実装して順次マージしています。
What I have done / 実施内容
Domain Layer
EmailValue Object (App\Packages\Domains\User\ValueObject\Email)findByEmailtoUserRepositroyInterfaceUserEntityandUserEntityFactoryto useEmailVOTokenServiceInterface(createToken,revokeAllTokens)Infra Layer
laravel/sanctumand published config (expiration: 1440 min = 1 day)personal_access_tokensmigrationHasApiTokenstrait toUsermodelSanctumTokenService(resolvesUserEloquent model fromUserEntityand delegates to Sanctum)TokenServiceInterface→SanctumTokenServiceinAppServiceProviderApplication Layer
AuthTokenDto(token: string,tokenType: string = 'Bearer')LoginUseCase::handle(string $email, string $password): AuthTokenDtofindByEmail→ entity null check →password_verify→createTokenInvalidArgumentException(→ 401)Presentation Layer
AuthController::loginwith 200 / 401 / 500 response handlingPOST /v1/user/loginrouteroutes/api.phpusingRoute::controller()->prefix()->group()groupingStatic Analysis (mago)
mago.tomlwith lint-based static analysis config (scoped toapp/Packages).github/workflows/static_analysis.ymlCI workflow (mago linton PR)Test Results / テスト結果
Integration Tests
LoginTest::test_login_returns_200_with_token_on_valid_credentialsLoginTest::test_login_returns_401_when_user_not_foundLoginTest::test_login_returns_401_on_wrong_passwordLoginTest::test_login_returns_500_on_unexpected_errorSanctumTokenServiceTest::test_createToken_returns_plain_text_tokenSanctumTokenServiceTest::test_createToken_throws_when_user_not_foundSanctumTokenServiceTest::test_revokeAllTokens_deletes_tokens_for_userSanctumTokenServiceTest::test_revokeAllTokens_throws_when_user_not_foundUserRepositoryTest::test_findByEmail_returns_entity_when_email_matchesUserRepositoryTest::test_findByEmail_returns_null_when_email_not_foundUnit Tests
LoginUseCaseTest::test_handle_returns_auth_token_dto_on_valid_credentialsLoginUseCaseTest::test_handle_throws_when_user_not_foundLoginUseCaseTest::test_handle_throws_when_password_does_not_matchCloses #405