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 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 mail
      javax.mail.MessagingException - If mail could not be sent - non-existent mail
      ObjectNotValidException - 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 input
      ObjectNotValidException - If input data fields are invalid