Class UsersControllerSecured

java.lang.Object
restapi.controllers.UsersControllerSecured

@RestController @RequestMapping("/users") final class UsersControllerSecured extends Object
  • Field Details

  • 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 token
      name - Display name for the user
      about - 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 token
      authUID - 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 token
      oldPassword - Old Password must match the saved password
      password - 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 token
      avatar - Avatar id
      Returns:
      Rest Message OK or Error 404