Package se.bth.pulse.controller
Class PasswordChangeRestController
java.lang.Object
se.bth.pulse.controller.PasswordChangeRestController
This class is a rest controller that serves the password change page.
-
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity
passwordChange
(String password, org.springframework.security.core.Authentication authentication) This method is used to change the password of the logged-in user.
-
Method Details
-
passwordChange
@PostMapping("/change-password") public org.springframework.http.ResponseEntity passwordChange(String password, org.springframework.security.core.Authentication authentication) This method is used to change the password of the logged-in user. It gets the username of the logged-in user from the authentication object. Then it gets the user object from the database using the username. Using the user object, it sets the new password and saves the user object. (Saving means updating the user object in the database when an id is already set)- Parameters:
password
- - the new passwordauthentication
- - used to get the username of the logged-in user- Returns:
- ResponseEntity - the response entity containing a success message if the password was changed successfully, an error message otherwise.
-