Class UserController


  • @RestController
    @RequestMapping("/users")
    public class UserController
    extends Object
    Class represent rest controller which is responsible for user operations
    • Constructor Detail

      • UserController

        public UserController()
    • Method Detail

      • register

        @PostMapping("/register")
        @ResponseStatus(CREATED)
        public GenericResponse register​(@Valid @RequestBody
                                        @Valid User user)
        Registeres a new user in the system
        Parameters:
        user - new user
        Returns:
        message containing whether operation was processed
      • login

        @PostMapping("/login")
        public JWTLoginSuccessResponse login​(@Valid @RequestBody
                                             @Valid UsernamePasswordVM usernamePasswordVM)
        Logs user in based on given credentials
        Parameters:
        usernamePasswordVM - username and password
        Returns:
        jwt for authentication
      • token

        @GetMapping("/token")
        public JWTLoginSuccessResponse token()
        Generates new token for authenticated user to avoid expiration
        Returns:
        jwt for authentication
      • updateUser

        @PutMapping("/updateUser")
        public GenericResponse updateUser​(@Valid @RequestBody
                                          @Valid UserUpdateVM userUpdateVM,
                                          User user)
        Updates user's personal information
        Parameters:
        userUpdateVM - updated username and email
        user - logged in user
        Returns:
        message containing whether operation was processed
      • updatePassword

        @PutMapping("/updatePassword")
        public GenericResponse updatePassword​(@Valid @RequestBody
                                              @Valid PasswordUpdateVM passwordUpdateVM,
                                              User user)
        Changes user's password
        Parameters:
        passwordUpdateVM - changed password
        user - logged in user
        Returns:
        message containing whether operation was processed