UserInfoController.java

  1. package edu.ucsb.cs156.courses.controllers;

  2. import edu.ucsb.cs156.courses.models.CurrentUser;
  3. import io.swagger.v3.oas.annotations.Operation;
  4. import io.swagger.v3.oas.annotations.tags.Tag;
  5. import org.springframework.security.access.prepost.PreAuthorize;
  6. import org.springframework.web.bind.annotation.GetMapping;
  7. import org.springframework.web.bind.annotation.RequestMapping;
  8. import org.springframework.web.bind.annotation.RestController;

  9. @Tag(name = "Current User Information")
  10. @RequestMapping("/api/currentUser")
  11. @RestController
  12. public class UserInfoController extends ApiController {

  13.   @Operation(summary = "Get information about current user")
  14.   @PreAuthorize("hasRole('ROLE_USER')")
  15.   @GetMapping("")
  16.   public CurrentUser getCurrentUser() {
  17.     return super.getCurrentUser();
  18.   }
  19. }