half auth
This commit is contained in:
parent
f13c0767c7
commit
eefdf4a072
@ -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") // Получение информации о сотруднике
|
||||||
|
Loading…
x
Reference in New Issue
Block a user