From b38016fe244bf27361850d70d9ffdb3072c6b443 Mon Sep 17 00:00:00 2001 From: Constantin Goeldel Date: Fri, 3 Nov 2023 14:39:36 +0100 Subject: [PATCH 1/2] Change Failure to Error --- src/user/user_impl.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/user/user_impl.rs b/src/user/user_impl.rs index e5ebe05..319baf9 100644 --- a/src/user/user_impl.rs +++ b/src/user/user_impl.rs @@ -113,13 +113,13 @@ impl<'r> FromRequest<'r> for User { let guard = request.guard().await; let auth: Auth = match guard { Success(auth) => auth, - Failure(x) => return Failure(x), + Error(x) => return Error(x), Forward(x) => return Forward(x), }; if let Some(user) = auth.get_user().await { Outcome::Success(user) } else { - Outcome::Failure((Status::Unauthorized, Error::UnauthorizedError)) + Outcome::Error((Status::Unauthorized, Self::Error::UnauthorizedError)) } } } @@ -132,7 +132,7 @@ impl<'r> FromRequest<'r> for AdminUser { let guard = request.guard().await; let auth: Auth = match guard { Success(auth) => auth, - Failure(x) => return Failure(x), + Error(x) => return Error(x), Forward(x) => return Forward(x), }; if let Some(user) = auth.get_user().await { @@ -140,7 +140,7 @@ impl<'r> FromRequest<'r> for AdminUser { return Outcome::Success(AdminUser(user)); } } - Outcome::Failure((Status::Unauthorized, Error::UnauthorizedError)) + Outcome::Error((Status::Unauthorized, Self::Error::UnauthorizedError)) } } From 62cb1c7c79d4fa58becd2f2cfeaf990caf68d8b8 Mon Sep 17 00:00:00 2001 From: Constantin Goeldel Date: Fri, 3 Nov 2023 13:42:31 +0000 Subject: [PATCH 2/2] fix to more occurences --- src/cookies.rs | 2 +- src/user/auth.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cookies.rs b/src/cookies.rs index aed56c9..536a7f4 100644 --- a/src/cookies.rs +++ b/src/cookies.rs @@ -34,7 +34,7 @@ impl<'r> FromRequest<'r> for Session { if let Some(session) = get_session(cookies) { Outcome::Success(session) } else { - Outcome::Failure((Status::Unauthorized, Error::UnauthorizedError)) + Outcome::Error((Status::Unauthorized, Error::UnauthorizedError)) } } } diff --git a/src/user/auth.rs b/src/user/auth.rs index d626cbf..84541ac 100644 --- a/src/user/auth.rs +++ b/src/user/auth.rs @@ -64,7 +64,7 @@ impl<'r> FromRequest<'r> for Auth<'r> { let users: &State = if let Outcome::Success(users) = req.guard().await { users } else { - return Outcome::Failure((Status::InternalServerError, Error::UnmanagedStateError)); + return Outcome::Error((Status::InternalServerError, Error::UnmanagedStateError)); }; Outcome::Success(Auth {