feat: implement Logout API across all layers / ユーザーログアウトAPIの全層実装#539
Merged
Conversation
feat: implement Infrastructure layer for User Logout / ユーザーログアウトのInfrastructure層実装
…ayer feat: implement Application layer for User Logout / ユーザーログアウトのApplication層実装
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## feat/user #539 +/- ##
===============================================
+ Coverage 61.75% 62.21% +0.45%
- Complexity 1585 1604 +19
===============================================
Files 132 135 +3
Lines 8153 8252 +99
===============================================
+ Hits 5035 5134 +99
Misses 3118 3118
🚀 New features to boost your workflow:
|
…layer feat: implement Presentation layer for User Logout / ユーザーログアウトのPresentation層実装
Closed
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/logoutAPI to invalidate the current session token using Laravel Sanctum.Each layer was developed on its own branch and merged in sequence.
現在のセッショントークンのみを無効化するログアウト機能(
POST /api/v1/user/logout)を実装しました。DDD の各層を個別ブランチで実装して順次マージしています。
What I have done / 実施内容
Infrastructure Layer
TokenServiceInterface:revokeCurrentToken(string $plainTextToken): voidを追加SanctumTokenService:PersonalAccessToken::findToken()でトークンを検索し削除。存在しない場合は何もしない(冪等)UserRepositroyInterfaceの変更なし(ログアウトはトークン削除のみで、ユーザーデータの取得は不要なため)Application Layer
LogoutUseCase:handle(string $plainTextToken): voidTokenServiceInterface::revokeCurrentToken($plainTextToken)を呼び出すPresentation Layer
AuthController:logoutアクションを追加$request->bearerToken()で現在のトークンを取得しLogoutUseCase::handle()に渡すroutes/api.php:POST /v1/user/logoutをauth:sanctumミドルウェア付きで登録Test Results / テスト結果
Integration Tests
SanctumTokenServiceTest::test_revokeCurrentToken_deletes_the_given_tokenSanctumTokenServiceTest::test_revokeCurrentToken_does_nothing_when_token_not_foundLogoutTest::test_logout_returns_200_when_authenticatedLogoutTest::test_logout_returns_401_when_unauthenticatedLogoutTest::test_logout_returns_500_on_unexpected_errorUnit Tests
LogoutUseCaseTest::test_handle_revokes_current_tokenLogoutUseCaseTest::test_handle_propagates_exception_when_revocation_failsCloses #408