UserInfoController.java
package edu.ucsb.cs156.courses.controllers;
import edu.ucsb.cs156.courses.entities.User;
import edu.ucsb.cs156.courses.models.CurrentUser;
import edu.ucsb.cs156.courses.services.CurrentUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Api(description="Current User Information")
@RequestMapping("/api/currentUser")
@RestController
public class UserInfoController extends ApiController {
@ApiOperation(value = "Get information about current user")
@PreAuthorize("hasRole('ROLE_USER')")
@GetMapping("")
public CurrentUser getCurrentUser() {
return super.getCurrentUser();
}
}