Package no.idata1002.group19.web.api
Class LoginController
java.lang.Object
no.idata1002.group19.web.api.LoginController
Represents a Login Controller class that provides RESTful
services to the /login endpoint with HTTP /POST mapping
for login requests.
- Since:
- 16.04.2023
- Version:
- 16.04.2023
- Author:
- Group19
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.security.authentication.AuthenticationManager
Returns the authentication manager.org.springframework.http.ResponseEntity<?>
getToken
(AccountCredentials credentials) Receives an HTTP POST request with the user's credentials and authenticates them.
-
Constructor Details
-
LoginController
public LoginController()
-
-
Method Details
-
getToken
@PostMapping("/login") public org.springframework.http.ResponseEntity<?> getToken(@RequestBody AccountCredentials credentials) Receives an HTTP POST request with the user's credentials and authenticates them. If the authentication is successful, it generates a token and sets the budget ID and authorization headers.- Parameters:
credentials
- An object that holds the user's credentials (username and password).- Returns:
- An HTTP response entity that includes a token in the Authorization header and the budget ID.
-
getAuthenticationManager
public org.springframework.security.authentication.AuthenticationManager getAuthenticationManager()Returns the authentication manager.- Returns:
- The authentication manager.
-