From 6235ff45b583949b413aa6986a90fdc073bcf9d9 Mon Sep 17 00:00:00 2001 From: Nutomic Date: Mon, 23 Oct 2023 18:17:26 +0200 Subject: [PATCH] Return status 401 on logout with invalid auth (fixes #4081) (#4082) * Return status 401 on logout with invalid auth (fixes #4081) * format --- crates/utils/src/error.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/utils/src/error.rs b/crates/utils/src/error.rs index 714fdfe56..9fa6bc508 100644 --- a/crates/utils/src/error.rs +++ b/crates/utils/src/error.rs @@ -56,6 +56,9 @@ impl Display for LemmyError { impl actix_web::error::ResponseError for LemmyError { fn status_code(&self) -> http::StatusCode { + if self.error_type == LemmyErrorType::IncorrectLogin { + return http::StatusCode::UNAUTHORIZED; + } match self.inner.downcast_ref::() { Some(diesel::result::Error::NotFound) => http::StatusCode::NOT_FOUND, _ => http::StatusCode::BAD_REQUEST,