Class ChangePasswordController
java.lang.Object
org.ntnu.idi.idatt2106.sparesti.sparestibackend.controller.ChangePasswordController
@RestController
@CrossOrigin
@RequestMapping("/forgotPassword")
public class ChangePasswordController
extends Object
Controller for managing forgotPassword endpoints
- Since:
- 20.4.24
- Version:
- 1.0
- Author:
- Lars N.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity
<String> changePasswordRequest
(ChangePasswordRequestRequest changePasswordRequestRequest) Parses a request for forgot password and sends a mail with a link for resetting password.org.springframework.http.ResponseEntity
<String> resetPassword
(ResetPasswordRequest resetPasswordRequest) Resets a user's password
-
Constructor Details
-
ChangePasswordController
public ChangePasswordController()
-
-
Method Details
-
changePasswordRequest
@PostMapping("/changePasswordRequest") public org.springframework.http.ResponseEntity<String> changePasswordRequest(@RequestBody ChangePasswordRequestRequest changePasswordRequestRequest) throws BadInputException, javax.mail.MessagingException, ObjectNotValidException Parses a request for forgot password and sends a mail with a link for resetting password. The response is always the same to prevent user's from finding each other's mails- Parameters:
changePasswordRequestRequest
- Wrapper for a user's mail- Returns:
- OK-string
- Throws:
BadInputException
- For invalid mailjavax.mail.MessagingException
- If mail could not be sent - non-existent mailObjectNotValidException
- If mail is invalid
-
resetPassword
@PostMapping("/resetPassword") public org.springframework.http.ResponseEntity<String> resetPassword(@RequestBody ResetPasswordRequest resetPasswordRequest) throws BadInputException, ObjectNotValidException Resets a user's password- Parameters:
resetPasswordRequest
- Wrapper for info for resetting password- Returns:
- OK-string
- Throws:
BadInputException
- For bad user inputObjectNotValidException
- If input data fields are invalid
-