Class UsersController

java.lang.Object
edu.ucsb.cs156.dining.controllers.ApiController
edu.ucsb.cs156.dining.controllers.UsersController

@RequestMapping("/api") @RestController public class UsersController extends ApiController
This is a REST controller for getting information about the users. These endpoints are only accessible to users with the role "ROLE_ADMIN".
  • 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.JsonProcessingException
      This 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.JsonProcessingException
      This 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 update
      approved - the new moderation status
      Returns:
      the updated user