private Task HandleUserAuthenticationExceptionAsync(HttpContext context, AuthenticationException exception) { context.Response.ContentType = "application/json"; context.Response.StatusCode = 401; return(context.Response.WriteAsync(exception.ToString())); }
private async Task AuthenticationExceptionHandler(HttpContext context, AuthenticationException authenticationException) { context.Response.StatusCode = (int)HttpStatusCode.BadRequest; var message = string.IsNullOrEmpty(authenticationException.Message) ? "Incorrect user name or password" : authenticationException.Message; if (isDevelopment) { await context.Response.WriteAsync(authenticationException.ToString()); } else { await context.Response.WriteAsync(message); } }