diff --git a/src/main/java/com/infinity/nto/controller/AdminController.java b/src/main/java/com/infinity/nto/controller/AdminController.java index 417e75f..68dc727 100644 --- a/src/main/java/com/infinity/nto/controller/AdminController.java +++ b/src/main/java/com/infinity/nto/controller/AdminController.java @@ -23,23 +23,22 @@ public class AdminController { private void amIAdmin() {} @PostMapping("/panel/get-employee-info") - private EmployeeDataDto getEmployeeInfo(@RequestParam("employee-login") String employeeLogin) { - Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + private EmployeeDataDto getEmployeeInfo(@RequestParam("employee-login") String employeeLogin, Authentication authentication) { String login = authentication.getName(); return adminService.getEmployeeInfo(employeeLogin, login); } @PostMapping("/panel/set-block-condition") private void setBlockCondition(@RequestParam("employee-login") String employeeLogin, - @RequestParam("block-condition") boolean blockCondition) { - Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + @RequestParam("block-condition") boolean blockCondition, + Authentication authentication) { String login = authentication.getName(); adminService.setBlockCondition(employeeLogin, blockCondition, login); } @PostMapping("/panel/get-employee-entry-list") - private List getEmployeeEntryList(@RequestParam("employee-login") String employeeLogin) { - Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + private List getEmployeeEntryList(@RequestParam("employee-login") String employeeLogin, + Authentication authentication) { String login = authentication.getName(); return adminService.getEmployeeEntryList(employeeLogin, login); } diff --git a/src/main/java/com/infinity/nto/controller/EmployeeController.java b/src/main/java/com/infinity/nto/controller/EmployeeController.java index 8b0dcc5..08ac960 100644 --- a/src/main/java/com/infinity/nto/controller/EmployeeController.java +++ b/src/main/java/com/infinity/nto/controller/EmployeeController.java @@ -20,29 +20,25 @@ public class EmployeeController { private void auth() {} @PostMapping("/info") - private EmployeeDataDto info() { - Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + private EmployeeDataDto info(Authentication authentication) { String login = authentication.getName(); return employeeService.info(login); } @PostMapping("/open") - private void open(@RequestParam("value") long value) { - Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + private void open(@RequestParam("value") long value, Authentication authentication) { String login = authentication.getName(); employeeService.open(login, value); } @PostMapping("/get-entry-list") - private List getEntryList() { - Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + private List getEntryList(Authentication authentication) { String login = authentication.getName(); return employeeService.getEntryList(login); } @PostMapping("/am-i-blocked") - private boolean amIBlocked() { - Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + private boolean amIBlocked(Authentication authentication) { String login = authentication.getName(); return employeeService.amIBlocked(login); }