Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement User Login #19

Open
poksyy opened this issue Feb 27, 2025 · 0 comments
Open

Implement User Login #19

poksyy opened this issue Feb 27, 2025 · 0 comments
Assignees
Labels
⬅️BACKEND ➕features New feature or request. 🧠 logic Handles business rules, data processing, and internal logic.

Comments

@poksyy
Copy link
Owner

poksyy commented Feb 27, 2025

  1. Create a DTO (LoginRequest)
    • This DTO will handle user login requests.
    • Include necessary fields: username and password.
    • Add validation annotations like @notblank.
  2. Implement Authentication in UserService
    • Inject AuthenticationManager to authenticate users.
    • Retrieve user details from the database using UserRepository.
    • Use BCryptPasswordEncoder.matches() to compare passwords.
    • Generate a JWT token if authentication is successful.
  3. Modify JwtService for Token Generation
    • Add a method to generate a token upon successful login.
    • Ensure the token includes user details for authorization.
  4. Build AuthController for Login
    • Create a /login endpoint in AuthController.
    • Call UserService to authenticate the user.
    • Return the generated JWT token upon successful authentication.
  5. Test Login in Postman
    • Send a POST request to /api/auth/login with JSON data:
    • Verify that a JWT token is returned in the response.
    • Use the token in subsequent requests for authentication.
{
    "username": "testuser",
    "password": "password123"
}
@poksyy poksyy added ➕features New feature or request. ⬅️BACKEND labels Feb 27, 2025
@poksyy poksyy moved this to Backlog in COPAY - Sprint 1 Feb 27, 2025
@poksyy poksyy moved this from Backlog to Todo in COPAY - Sprint 1 Feb 27, 2025
@poksyy poksyy self-assigned this Feb 27, 2025
@krschan krschan added the 🧠 logic Handles business rules, data processing, and internal logic. label Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⬅️BACKEND ➕features New feature or request. 🧠 logic Handles business rules, data processing, and internal logic.
Projects
Status: Todo
Development

No branches or pull requests

2 participants