Package com.myhrcrmproject.controller
Class AuthController
java.lang.Object
com.myhrcrmproject.controller.AuthController
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<AuthResponse>authenticate(@Valid AuthRequest authRequest) Endpoint for authenticating a user and generating a JWT token.org.springframework.http.ResponseEntity<UserDetailsResponseDTO>registerNewUser(@Valid UserDetailsRequestDTO request) Endpoint for registering a new user.
-
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
ResponseEntitywith 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
ResponseEntitywith the details of the newly registered user.
-