Class UserController
- java.lang.Object
-
- cz.zcu.students.cacha.bp_server.controllers.UserController
-
@RestController @RequestMapping("/users") public class UserController extends Object
Class represent rest controller which is responsible for user operations
-
-
Constructor Summary
Constructors Constructor Description UserController()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JWTLoginSuccessResponse
login(@Valid UsernamePasswordVM usernamePasswordVM)
Logs user in based on given credentialsGenericResponse
register(@Valid User user)
Registeres a new user in the systemJWTLoginSuccessResponse
token()
Generates new token for authenticated user to avoid expirationGenericResponse
updatePassword(@Valid PasswordUpdateVM passwordUpdateVM, User user)
Changes user's passwordGenericResponse
updateUser(@Valid UserUpdateVM userUpdateVM, User user)
Updates user's personal information
-
-
-
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 emailuser
- 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 passworduser
- logged in user- Returns:
- message containing whether operation was processed
-
-