half auth

This commit is contained in:
truettwo 2025-02-19 15:00:06 +03:00
parent f13c0767c7
commit eefdf4a072

View File

@ -20,17 +20,9 @@ public class EmployeeController {
this.employeeService = employeeService; this.employeeService = employeeService;
} }
@PostMapping("/auth") // Аутентификация @GetMapping("/auth") // Проверка аутентификации
public ResponseEntity<?> authenticate(@RequestBody Map<String, String> payload) { public ResponseEntity<?> authenticate() {
String login = payload.get("login"); return ResponseEntity.ok("Authenticated successfully");
String password = payload.get("password");
Optional<Employee> employee = employeeService.findByLogin(login);
if (employee.isPresent() && employee.get().getPassword().equals(password)) {
return ResponseEntity.ok("Valid login");
} else {
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body("Invalid login or password");
}
} }
@GetMapping("/{login}/info") // Получение информации о сотруднике @GetMapping("/{login}/info") // Получение информации о сотруднике