Repository navigation
feat: user login - #37
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request implements a user login/authentication feature using JWT tokens and refactors user creation DTOs for improved naming consistency. The implementation follows the existing codebase patterns with a clean separation between API layer (controllers), application layer (use-cases/services), and domain layer (entities), along with comprehensive test coverage.
Key Changes:
- Added JWT-based login functionality with
/loginendpoint that authenticates users via email/password and returns access tokens - Refactored DTO naming from
CreateUserDtotoCreateUserRequestDtofor consistency with newLoginRequestDtopattern - Enhanced User entity with
validatePasswordmethod to encapsulate password validation logic
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
src/api/users/controllers/login.controller.ts |
New controller exposing POST /login endpoint with OpenAPI documentation |
src/api/users/users.module.ts |
Configured JwtModule with global registration and added LoginController/LoginService providers |
src/application/users/use-cases/login.service.ts |
Core authentication logic validating credentials and generating JWT tokens |
src/application/users/dtos/login-request.dto.ts |
Request DTO with validation for email/password login fields |
src/application/users/dtos/login-response.dto.ts |
Response DTO defining login success structure with access token |
src/domain/users/entities/user.entity.ts |
Added validatePassword method delegating to Password value object |
src/application/users/dtos/create-user-request.dto.ts |
Renamed from CreateUserDto for naming consistency |
src/application/users/use-cases/create-user.service.ts |
Updated import to use renamed CreateUserRequestDto |
src/api/users/controllers/create-user.controller.ts |
Updated import to use renamed CreateUserRequestDto |
tests/unit/application/users/use-cases/login.service.test.ts |
Unit tests covering login success, invalid credentials, and non-existent user scenarios |
tests/integration/api/users/controllers/login.controller.test.ts |
Integration tests validating API behavior including validation errors and authentication flows |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
This pull request introduces a user authentication (login) feature and refactors user creation DTOs for improved clarity and consistency. The main changes include the implementation of the login endpoint, supporting DTOs and services, and comprehensive tests for the new functionality. Additionally, the user creation flow now uses a more descriptive DTO name.
Authentication Feature Implementation:
LoginControllerwith a/loginendpoint, allowing users to authenticate with their email and password. The controller uses a newLoginServiceto handle authentication logic and returns a JWT access token upon successful login. [1] [2]LoginRequestDtoandLoginResponseDtoto clearly define the expected request and response structures for the login endpoint. [1] [2]JwtModuleglobally inusers.module.tsto support JWT operations for authentication.User Creation Refactor:
CreateUserDtotoCreateUserRequestDtothroughout the codebase for better clarity and consistency in DTO naming. [1] [2] [3] [4] [5]Testing Enhancements:
Domain Model Update:
validatePasswordmethod to theUserentity to encapsulate password validation logic.