From 02c25075e5e5223e31f6870ee3ba3e8845e7c100 Mon Sep 17 00:00:00 2001 From: Sven-Hendrik Haase Date: Tue, 19 Jul 2022 06:50:26 +0200 Subject: Bump deps --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- src/auth.rs | 10 ++++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b196739..d4dd21f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -244,9 +244,9 @@ dependencies = [ [[package]] name = "actix-web-httpauth" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08c25a48b4684f90520183cd1a688e5f4f7e9905835fa75d02c0fe4f60fcdbe6" +checksum = "a6dc1123f18b3548b9fe90c15e9bd77819701b047c6b62c152230aa39243d40d" dependencies = [ "actix-service", "actix-utils", diff --git a/Cargo.toml b/Cargo.toml index 4bb3d44..b8d90e4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ panic = 'abort' actix-web = "4" actix-files = "0.6" actix-multipart = "0.4" -actix-web-httpauth = "0.6" +actix-web-httpauth = "0.7" maud = "0.23" yansi = "0.5" simplelog = "0.12" diff --git a/src/auth.rs b/src/auth.rs index 1b11557..b2c01e3 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -77,16 +77,18 @@ pub struct CurrentUser { pub async fn handle_auth( req: ServiceRequest, cred: BasicAuth, -) -> actix_web::Result { +) -> actix_web::Result { let required_auth = &req.app_data::().unwrap().auth; req.extensions_mut().insert(CurrentUser { name: cred.user_id().to_string(), }); - match_auth(&cred.into(), required_auth) - .then(|| req) - .ok_or_else(|| ContextualError::InvalidHttpCredentials.into()) + if match_auth(&cred.into(), required_auth) { + Ok(req) + } else { + Err((ContextualError::InvalidHttpCredentials.into(), req)) + } } #[rustfmt::skip] -- cgit v1.2.3