412 Error code for change state request
This commit is contained in:
parent
d3390792a1
commit
aaa550d718
@ -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")
|
@Operation(description = "Enable/Disable user's ability to use QR code entrance. (ADMIN only)", summary = "Enable/Disable QR")
|
||||||
@ApiResponses(value = {
|
@ApiResponses(value = {
|
||||||
@ApiResponse(responseCode = "200", description = "Modification Successful"),
|
@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 = "401", description = "Unauthorized"),
|
||||||
@ApiResponse(responseCode = "403", description = "Forbidden"),
|
@ApiResponse(responseCode = "403", description = "Forbidden"),
|
||||||
@ApiResponse(responseCode = "404", description = "User not found"),
|
@ApiResponse(responseCode = "404", description = "User not found"),
|
||||||
@ApiResponse(responseCode = "400", description = "State doesn't exist"),
|
|
||||||
})
|
})
|
||||||
public ResponseEntity<HttpStatusCode> changeState(@PathVariable String login) {
|
public ResponseEntity<HttpStatusCode> changeState(@PathVariable String login) {
|
||||||
return employeeService.changeState(login);
|
return employeeService.changeState(login);
|
||||||
|
@ -90,7 +90,7 @@ public class EmployeeServiceImpl implements EmployeeService {
|
|||||||
Employee e = employeeRepository.findByLogin(login);
|
Employee e = employeeRepository.findByLogin(login);
|
||||||
if(e != null) {
|
if(e != null) {
|
||||||
if (Objects.equals(e.getAuthorities().iterator().next().getAuthority(), "ADMIN")) {
|
if (Objects.equals(e.getAuthorities().iterator().next().getAuthority(), "ADMIN")) {
|
||||||
return new ResponseEntity<>(HttpStatus.UNAUTHORIZED);
|
return new ResponseEntity<>(HttpStatus.PRECONDITION_FAILED);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
e.setIsQREnabled(!e.getIsQREnabled());
|
e.setIsQREnabled(!e.getIsQREnabled());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user