|
|
@@ -6,6 +6,7 @@ import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.security.core.context.SecurityContext;
|
|
|
import org.springframework.security.core.context.SecurityContextHolder;
|
|
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
|
|
@@ -13,6 +14,9 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
@Slf4j
|
|
|
@RestController
|
|
|
@AllArgsConstructor
|
|
|
@@ -20,7 +24,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
@RequestMapping("api/users")
|
|
|
public class UserController {
|
|
|
|
|
|
- @GetMapping
|
|
|
+ @GetMapping("current")
|
|
|
public ResponseEntity<Object> get() {
|
|
|
SecurityContext context = SecurityContextHolder.getContext();
|
|
|
Object principal = context.getAuthentication().getPrincipal();
|
|
|
@@ -31,4 +35,10 @@ public class UserController {
|
|
|
return ResponseEntity.status(HttpStatus.FORBIDDEN).build();
|
|
|
}
|
|
|
|
|
|
+ @GetMapping
|
|
|
+ @PreAuthorize("hasAuthority('ADMIN')")
|
|
|
+ public ResponseEntity<List<Object>> getAll() {
|
|
|
+ return ResponseEntity.ok(new ArrayList<>());
|
|
|
+ }
|
|
|
+
|
|
|
}
|