Package restapi.controllers
Class UsersControllerSecured
java.lang.Object
restapi.controllers.UsersControllerSecured
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final @NonNull UserAuthenticationService
private final @NonNull FirebaseService
private final @NonNull UserService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<RestResponse>
changeAvatar
(LoggedUser user, int avatar) Edit user's avatar's id.org.springframework.http.ResponseEntity<RestResponse>
changePassword
(LoggedUser user, String oldPassword, String password) Change Password endpoint /users/psworg.springframework.http.ResponseEntity<RestResponse>
changePhone
(LoggedUser user, String authUID) Edit user's phone number.org.springframework.http.ResponseEntity<RestResponse>
editInfo
(LoggedUser user, String name, String about) Edit user's name and/or about endpoint /users/editInfoorg.springframework.http.ResponseEntity<RestResponse>
getCurrent
(LoggedUser user) Get user's details endpoint /users/currentorg.springframework.http.ResponseEntity<RestResponse>
logout
(LoggedUser user) Logout: Ends users session, and revokes permission to user's token endpoint /users/logout
-
Field Details
-
authentication
-
userService
-
authService
-
-
Constructor Details
-
UsersControllerSecured
UsersControllerSecured()
-
-
Method Details
-
getCurrent
@GetMapping("/current") public org.springframework.http.ResponseEntity<RestResponse> getCurrent(@AuthenticationPrincipal LoggedUser user) Get user's details endpoint /users/current- Parameters:
user
- Authenticated LoggedUser from token- Returns:
- user's details
-
logout
@PostMapping("/logout") public org.springframework.http.ResponseEntity<RestResponse> logout(@AuthenticationPrincipal LoggedUser user) Logout: Ends users session, and revokes permission to user's token endpoint /users/logout- Parameters:
user
- Authenticated LoggedUser from token- Returns:
- Rest Message OK
-
editInfo
@PutMapping("/editInfo") public org.springframework.http.ResponseEntity<RestResponse> editInfo(@AuthenticationPrincipal LoggedUser user, @Param("name") String name, @Param("about") String about) Edit user's name and/or about endpoint /users/editInfo- Parameters:
user
- Authenticated LoggedUser from tokenname
- Display name for the userabout
- Custom additional information- Returns:
- Rest Message OK or Error 404
-
changePhone
@PutMapping("/editPhone") public org.springframework.http.ResponseEntity<RestResponse> changePhone(@AuthenticationPrincipal LoggedUser user, @RequestParam("authUID") String authUID) Edit user's phone number. Phone number must be previously verified by Firebase. Parameter must be the returned authUID from Firebase. endpoint /users/editPhone- Parameters:
user
- Authenticated LoggedUser from tokenauthUID
- Firebase authUID corresponding to a user logged with phone- Returns:
- Rest Message OK or Error 404
-
changePassword
@PutMapping("/psw") public org.springframework.http.ResponseEntity<RestResponse> changePassword(@AuthenticationPrincipal LoggedUser user, @RequestParam("old") String oldPassword, @RequestParam("password") String password) Change Password endpoint /users/psw- Parameters:
user
- Authenticated LoggedUser from tokenoldPassword
- Old Password must match the saved passwordpassword
- New password for the user- Returns:
- Rest Message OK or Error 404, 409 or 401
-
changeAvatar
@PutMapping("/avatar") public org.springframework.http.ResponseEntity<RestResponse> changeAvatar(@AuthenticationPrincipal LoggedUser user, @RequestParam("avatar") int avatar) Edit user's avatar's id. endpoint /users/avatar- Parameters:
user
- Authenticated LoggedUser from tokenavatar
- Avatar id- Returns:
- Rest Message OK or Error 404
-