use of org.eclipse.openvsx.json.ErrorJson in project openvsx by eclipse.
the class UserAPI method getAuthError.
/**
* Retrieve the last authentication error and return its details.
*/
@GetMapping(path = "/user/auth-error", produces = MediaType.APPLICATION_JSON_VALUE)
public ErrorJson getAuthError(HttpServletRequest request) {
var authException = request.getSession().getAttribute(WebAttributes.AUTHENTICATION_EXCEPTION);
if (!(authException instanceof AuthenticationException))
throw new ResponseStatusException(HttpStatus.NOT_FOUND);
var json = new ErrorJson();
json.message = ((AuthenticationException) authException).getMessage();
if (authException instanceof CodedAuthException)
json.code = ((CodedAuthException) authException).getCode();
return json;
}
Aggregations