Class AccountResource


  • @RestController
    @RequestMapping("/api")
    public class AccountResource
    extends Object
    REST controller for managing the current user's account.
    • Method Detail

      • registerAccount

        @PostMapping("/register")
        @ResponseStatus(CREATED)
        public void registerAccount​(@Valid @RequestBody
                                    @Valid ManagedUserVM managedUserVM)
                             throws javax.mail.MessagingException
        POST /register : register the user.
        Parameters:
        managedUserVM - the managed user View Model.
        Throws:
        InvalidPasswordException - 400 (Bad Request) if the password is incorrect.
        EmailAlreadyUsedException - 400 (Bad Request) if the email is already used.
        LoginAlreadyUsedException - 400 (Bad Request) if the login is already used.
        javax.mail.MessagingException
      • activateAccount

        @GetMapping("/activate")
        public void activateAccount​(@RequestParam("key")
                                    String key)
        GET /activate : activate the registered user.
        Parameters:
        key - the activation key.
        Throws:
        RuntimeException - 500 (Internal Server Error) if the user couldn't be activated.
      • isAuthenticated

        @GetMapping("/authenticate")
        public String isAuthenticated​(javax.servlet.http.HttpServletRequest request)
        GET /authenticate : check if the user is authenticated, and return its login.
        Parameters:
        request - the HTTP request.
        Returns:
        the login if the user is authenticated.
      • getAccount

        @Transactional
        @GetMapping("/account")
        public UserDTO getAccount()
        GET /account : get the current user.
        Returns:
        the current user.
        Throws:
        RuntimeException - 500 (Internal Server Error) if the user couldn't be returned.
      • saveAccount

        @Transactional
        @PostMapping("/account")
        public void saveAccount​(@Valid @RequestBody
                                @Valid UserDTO userDTO)
        POST /account : update the current user information.
        Parameters:
        userDTO - the current user information.
        Throws:
        EmailAlreadyUsedException - 400 (Bad Request) if the email is already used.
        RuntimeException - 500 (Internal Server Error) if the user login wasn't found.
      • changePassword

        @PostMapping(path="/account/change-password")
        public void changePassword​(@RequestBody
                                   PasswordChangeDTO passwordChangeDto)
        POST /account/change-password : changes the current user's password.
        Parameters:
        passwordChangeDto - current and new password.
        Throws:
        InvalidPasswordException - 400 (Bad Request) if the new password is incorrect.
      • requestPasswordReset

        @PostMapping(path="/account/reset-password/init")
        public void requestPasswordReset​(@RequestBody
                                         String mail)
                                  throws javax.mail.MessagingException
        POST /account/reset-password/init : Send an email to reset the password of the user.
        Parameters:
        mail - the mail of the user.
        Throws:
        javax.mail.MessagingException
      • finishPasswordReset

        @PostMapping(path="/account/reset-password/finish")
        public void finishPasswordReset​(@RequestBody
                                        KeyAndPasswordVM keyAndPassword)
        POST /account/reset-password/finish : Finish to reset the password of the user.
        Parameters:
        keyAndPassword - the generated key and the new password.
        Throws:
        InvalidPasswordException - 400 (Bad Request) if the password is incorrect.
        RuntimeException - 500 (Internal Server Error) if the password could not be reset.