Return status 401 on logout with invalid auth (fixes #4081) (#4082)

* Return status 401 on logout with invalid auth (fixes #4081)

* format
This commit is contained in:
Nutomic 2023-10-23 18:17:26 +02:00 committed by GitHub
parent ec0a707110
commit 6235ff45b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -56,6 +56,9 @@ impl Display for LemmyError {
impl actix_web::error::ResponseError for LemmyError { impl actix_web::error::ResponseError for LemmyError {
fn status_code(&self) -> http::StatusCode { fn status_code(&self) -> http::StatusCode {
if self.error_type == LemmyErrorType::IncorrectLogin {
return http::StatusCode::UNAUTHORIZED;
}
match self.inner.downcast_ref::<diesel::result::Error>() { match self.inner.downcast_ref::<diesel::result::Error>() {
Some(diesel::result::Error::NotFound) => http::StatusCode::NOT_FOUND, Some(diesel::result::Error::NotFound) => http::StatusCode::NOT_FOUND,
_ => http::StatusCode::BAD_REQUEST, _ => http::StatusCode::BAD_REQUEST,