412 Error code for change state request

This commit is contained in:
Индекс Зиро 2025-02-20 14:55:03 +03:00
parent d3390792a1
commit aaa550d718
2 changed files with 2 additions and 2 deletions

View File

@ -72,10 +72,10 @@ public class EmployeeController {
@Operation(description = "Enable/Disable user's ability to use QR code entrance. (ADMIN only)", summary = "Enable/Disable QR")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Modification Successful"),
@ApiResponse(responseCode = "412", description = "User you're trying to block has ADMIN privileges"),
@ApiResponse(responseCode = "401", description = "Unauthorized"),
@ApiResponse(responseCode = "403", description = "Forbidden"),
@ApiResponse(responseCode = "404", description = "User not found"),
@ApiResponse(responseCode = "400", description = "State doesn't exist"),
})
public ResponseEntity<HttpStatusCode> changeState(@PathVariable String login) {
return employeeService.changeState(login);

View File

@ -90,7 +90,7 @@ public class EmployeeServiceImpl implements EmployeeService {
Employee e = employeeRepository.findByLogin(login);
if(e != null) {
if (Objects.equals(e.getAuthorities().iterator().next().getAuthority(), "ADMIN")) {
return new ResponseEntity<>(HttpStatus.UNAUTHORIZED);
return new ResponseEntity<>(HttpStatus.PRECONDITION_FAILED);
}
else {
e.setIsQREnabled(!e.getIsQREnabled());