Class AuthController

java.lang.Object
com.myhrcrmproject.controller.AuthController

@RestController @RequestMapping("/api/auth") public class AuthController extends Object
Controller class for handling authentication and user registration endpoints.

This class provides RESTful endpoints for authenticating users and registering new users. It interacts with the AuthenticationManager for user authentication and the UserDetailsServiceImpl for user registration.

Additionally, it uses the JwtTokenProvider for generating JWT tokens upon successful user authentication.

The class is annotated with @RestController to indicate its role as a Spring REST controller, and it is mapped to the "/api/auth" endpoint.

Version:
1.0
Author:
Denys Chaykovskyy
  • Constructor Details

    • AuthController

      public AuthController()
  • Method Details

    • authenticate

      @PostMapping public org.springframework.http.ResponseEntity<AuthResponse> authenticate(@Valid @RequestBody @Valid AuthRequest authRequest)
      Endpoint for authenticating a user and generating a JWT token.
      Parameters:
      authRequest - The request body containing user credentials (username and password).
      Returns:
      A ResponseEntity with the JWT token upon successful authentication.
    • registerNewUser

      @PostMapping("/register") public org.springframework.http.ResponseEntity<UserDetailsResponseDTO> registerNewUser(@Valid @RequestBody @Valid UserDetailsRequestDTO request)
      Endpoint for registering a new user.
      Parameters:
      request - The request body containing user credentials and email.
      Returns:
      A ResponseEntity with the details of the newly registered user.