feat: implement login use case and dtos#11
Open
Otavio2704 wants to merge 6 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Implements the core application-layer login flow for the auth module by introducing a LoginUseCase contract + implementation, request/response DTOs, and HTTP exception mapping for authentication-related errors.
Changes:
- Added
LoginUseCaseandLoginUseCaseImplto authenticate by email/password and enforceAccountStatus.ACTIVE. - Added
LoginRequestDTO(input) andLoginResponseDTO(output) for the login use case. - Extended
RestExceptionHandlerto mapInvalidCredentialsException→ 401 andAccountNotActiveException→ 403, plus added unit tests for login success/error paths.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| auth/src/main/java/com/brabank/auth/application/usecases/contracts/LoginUseCase.java | Introduces the login use case contract. |
| auth/src/main/java/com/brabank/auth/application/usecases/impl/LoginUseCaseImpl.java | Implements authentication rules and returns a login response DTO. |
| auth/src/main/java/com/brabank/auth/adapters/in/dtos/LoginRequestDTO.java | Adds validated input DTO for login. |
| auth/src/main/java/com/brabank/auth/adapters/out/dtos/LoginResponseDTO.java | Adds output DTO for login results (id/email/status/role). |
| auth/src/main/java/com/brabank/auth/infrastructure/exceptions/InvalidCredentialsException.java | Adds exception representing invalid login credentials. |
| auth/src/main/java/com/brabank/auth/infrastructure/exceptions/AccountNotActiveException.java | Adds exception representing non-active accounts attempting login. |
| auth/src/main/java/com/brabank/auth/infrastructure/exceptions/RestExceptionHandler.java | Maps new auth exceptions to 401/403 responses. |
| auth/src/test/java/com/brabank/auth/application/usecases/impl/LoginUseCaseImplTest.java | Adds unit tests covering login success and failure scenarios. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+38
to
+43
| return new LoginResponseDTO( | ||
| identity.getId(), | ||
| identity.getEmail(), | ||
| identity.getStatus(), | ||
| identity.getRole() | ||
| ); |
Comment on lines
+56
to
+59
| assertEquals(identity.getId(), response.id()); | ||
| assertEquals("user@brabank.com", response.email()); | ||
| assertEquals(AccountStatus.ACTIVE, response.status()); | ||
| assertEquals(Role.CLIENT, response.role()); |
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.
Description
Implementação do caso de uso de Login (
LoginUseCase) e DTOs de entrada e saída correspondentes. Este é o PR 2 da implementação do endpoint de login.Type of change
Changes made
LoginRequestDTOeLoginResponseDTO.LoginUseCasee sua implementaçãoLoginUseCaseImplcom regras de negócio de autenticação.InvalidCredentialsExceptioneAccountNotActiveException) noRestExceptionHandlerpara retornar 401 e 403 respectivamente.Notes for reviewers
Este PR depende das alterações feitas no PR 1 (método
findByEmailno repositório), as quais já foram mescladas nesta branch localmente. A verificação do hash de senha utiliza BCrypt viaPasswordEncoder.Checklist