Class UsersController

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

@RequestMapping("/api/admin/users") @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("") 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
    • allProfessors

      @PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("/professors") public Iterable<Map<String,Object>> allProfessors()
      This method returns a list of all Recommendation Requests requested by current student.
      Returns:
      a list of all Recommendation Requests requested by the current user
    • users

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @GetMapping("/get") public User users(@RequestParam Long id) throws com.fasterxml.jackson.core.JsonProcessingException
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • deleteUser_Admin

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @DeleteMapping("/delete") public Object deleteUser_Admin(@RequestParam Long id)
    • toggleAdmin

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PostMapping("/toggleAdmin") public Object toggleAdmin(@RequestParam Long id)
    • toggleProfessor

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PostMapping("/toggleProfessor") public Object toggleProfessor(@RequestParam Long id)
    • toggleStudent

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PostMapping("/toggleStudent") public Object toggleStudent(@RequestParam Long id)