diff --git a/src/handlers/user.rs b/src/handlers/user.rs index afa5bdf..6eb0a6a 100644 --- a/src/handlers/user.rs +++ b/src/handlers/user.rs @@ -29,12 +29,12 @@ pub async fn get_current_user_handler( .headers() .get("Authorization") .and_then(|header_value| header_value.to_str().ok()) - .and_then(|auth_str| { + .map(|auth_str| { // Убираем префикс "Bearer " если он есть - if auth_str.starts_with("Bearer ") { - Some(&auth_str[7..]) + if let Some(stripped) = auth_str.strip_prefix("Bearer ") { + stripped } else { - Some(auth_str) + auth_str } });