From f12f81d584982144a94db396450e2cdbe938d8a5 Mon Sep 17 00:00:00 2001 From: Radical Date: Sun, 4 May 2025 21:30:33 +0200 Subject: [PATCH] fix: extract auth value --- src/utils.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/utils.rs b/src/utils.rs index 56b43fa..d80bed4 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -13,5 +13,11 @@ pub fn get_auth_header(headers: &HeaderMap) -> Result<&str, HttpResponse> { return Err(HttpResponse::Unauthorized().json(format!(r#" {{ "error": "{}" }} "#, error))); } - Ok(auth.unwrap()) + let auth_value = auth.unwrap().split_whitespace().nth(1); + + if let None = auth_value { + return Err(HttpResponse::BadRequest().finish()); + } + + Ok(auth_value.unwrap()) }