Class AuthenticationController
java.lang.Object
callofproject.dev.authentication.controller.AuthenticationController
@RestController
@RequestMapping("api/auth/authenticate")
public class AuthenticationController
extends Object
Authentication Controller
Copyleft (C), 2023, Cal-of-Project-Teams Developers.
All Rights free.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor for the AuthenticationController class. -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<Object>
authenticate
(@Valid AuthenticationRequest request) Login operation for application.org.springframework.http.ResponseEntity<Object>
findUserByUsername
(String username) Find user by username.org.springframework.http.ResponseEntity<Object>
refreshToken
(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Deprecated.org.springframework.http.ResponseEntity<Object>
register
(@Valid RegisterRequest request) Register to application.org.springframework.http.ResponseEntity<Object>
validateToken
(String token) Validate the token with given token.org.springframework.http.ResponseEntity<Object>
Verify the user and register to application.
-
Constructor Details
-
AuthenticationController
public AuthenticationController(@Qualifier("callofproject.dev.authentication.service.authentication") AuthenticationService service) Constructor for the AuthenticationController class. It is used to inject dependencies into the controller.- Parameters:
service
- The AuthenticationService object to be injected.
-
-
Method Details
-
findUserByUsername
@GetMapping("/find/username") public org.springframework.http.ResponseEntity<Object> findUserByUsername(@RequestParam("username") String username) Find user by username.- Parameters:
username
- represent the username.- Returns:
- if success returns User else return ErrorMessage.
-
register
@PostMapping("/register") public org.springframework.http.ResponseEntity<Object> register(@Valid @RequestBody @Valid RegisterRequest request) Register to application.- Parameters:
request
- represent the Register information.- Returns:
- if success AuthenticationResponse else return ErrorMessage.
-
verify
@GetMapping("/register/verify") public org.springframework.http.ResponseEntity<Object> verify(@RequestParam("token") String token) Verify the user and register to application.- Parameters:
token
- represent the token that sent to user.- Returns:
- if success AuthenticationResponse else return ErrorMessage.
-
authenticate
@PostMapping("/login") public org.springframework.http.ResponseEntity<Object> authenticate(@RequestBody @Valid @Valid AuthenticationRequest request) Login operation for application.- Parameters:
request
- represent the login information.- Returns:
- if success returns AuthenticationResponse that include token and status else return ErrorMessage.
-
refreshToken
@Deprecated @PostMapping("/refresh-token") public org.springframework.http.ResponseEntity<Object> refreshToken(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Deprecated.Refresh token- Parameters:
request
- from Servletresponse
- from Servlet- Returns:
- success or not. Return type is boolean.
-
validateToken
@GetMapping("/validate") public org.springframework.http.ResponseEntity<Object> validateToken(@RequestParam("token") String token) Validate the token with given token.- Parameters:
token
- represent the request token- Returns:
- success or not. Return type is boolean.
-