Class UsersController
java.lang.Object
edu.ucsb.cs156.dining.controllers.ApiController
edu.ucsb.cs156.dining.controllers.UsersController
This is a REST controller for getting information about the users.
These endpoints are only accessible to users with the role "ROLE_ADMIN".
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity
<String> This method returns list of all users with a proposed alias.updateAliasModeration
(long id, Boolean approved) This method allows an admin to update the moderation status of a user's alias.org.springframework.http.ResponseEntity
<User> updateProposedAlias
(String proposedAlias) This method allows the user to update their alias.org.springframework.http.ResponseEntity
<String> users()
This method returns a list of all users.Methods inherited from class edu.ucsb.cs156.dining.controllers.ApiController
genericMessage, getCurrentUser, handleGenericException
-
Constructor Details
-
UsersController
public UsersController()
-
-
Method Details
-
users
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @GetMapping("/admin/users") public org.springframework.http.ResponseEntity<String> users() throws com.fasterxml.jackson.core.JsonProcessingExceptionThis method returns a list of all users. Accessible only to users with the role "ROLE_ADMIN".- Returns:
- a list of all users
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
- if there is an error processing the JSON
-
getUsersWithProposedAlias
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @GetMapping("/admin/usersWithProposedAlias") public org.springframework.http.ResponseEntity<String> getUsersWithProposedAlias() throws com.fasterxml.jackson.core.JsonProcessingExceptionThis method returns list of all users with a proposed alias.- Returns:
- a list of users with a proposed alias
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
- if there is an error processing the JSON
-
updateProposedAlias
@PreAuthorize("hasRole(\'ROLE_USER\')") @PostMapping("/currentUser/updateAlias") public org.springframework.http.ResponseEntity<User> updateProposedAlias(@RequestParam String proposedAlias) This method allows the user to update their alias.- Parameters:
proposedAlias
- the new alias- Returns:
- the updated user
-
updateAliasModeration
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("/currentUser/updateAliasModeration") public User updateAliasModeration(@RequestParam long id, @RequestParam Boolean approved) This method allows an admin to update the moderation status of a user's alias.- Parameters:
id
- the id of the user to updateapproved
- the new moderation status- Returns:
- the updated user
-