removed lets and used only match in
This commit is contained in:
parent
5f81817f32
commit
5ef5f48654
14
src/lib.rs
14
src/lib.rs
|
@ -26,19 +26,21 @@ pub fn authenticated_route(_: TokenStream, mut input: TokenStream) -> TokenStrea
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! authenticate_route {
|
macro_rules! authenticate_route {
|
||||||
($request:expr, $client:expr) => {
|
($request:expr, $client:expr) => {
|
||||||
let header_conversion_result: dev_dtos::dtos::user::user_dtos::UserAuthHeader = match serde_json::from_str(match $request.headers().get("authentication") {
|
match serde_json::from_str::<dev_dtos::dtos::user::user_dtos::UserAuthHeader>(match $request.headers().get("authentication") {
|
||||||
Some(auth_header) => match auth_header.to_str() {
|
Some(auth_header) => match auth_header.to_str() {
|
||||||
Ok(string) => string,
|
Ok(string) => string,
|
||||||
Err(_) => return actix_web_utils::extensions::typed_response::TypedHttpResponse::return_standard_error(400, err::MessageResource::new_from_str("Auth header in incorrect format.")),
|
Err(_) => return actix_web_utils::extensions::typed_response::TypedHttpResponse::return_standard_error(400, err::MessageResource::new_from_str("Auth header in incorrect format.")),
|
||||||
},
|
},
|
||||||
None => return actix_web_utils::extensions::typed_response::TypedHttpResponse::return_standard_error(401, err::MessageResource::new_from_str("No auth header present.")),
|
None => return actix_web_utils::extensions::typed_response::TypedHttpResponse::return_standard_error(401, err::MessageResource::new_from_str("No auth header present.")),
|
||||||
}) {
|
}) {
|
||||||
Ok(user_for_authentication) => user_for_authentication,
|
Ok(user_for_authentication) => {
|
||||||
Err(error) => return actix_web_utils::extensions::typed_response::TypedHttpResponse::return_standard_error(401, err::MessageResource::new_from_string(error.to_string())),
|
match dev_communicators::middleware::user_svc::user_service::authenticate_user_with_token($client, &user_for_authentication.into()).await {
|
||||||
};
|
Ok(authed_user) => authed_user,
|
||||||
match dev_communicators::middleware::user_svc::user_service::authenticate_user_with_token($client, &header_conversion_result.into()).await {
|
Err(error) => return actix_web_utils::extensions::typed_response::TypedHttpResponse::return_standard_error(401, err::MessageResource::new_from_string(error.to_string())),
|
||||||
Ok(authed_user) => authed_user,
|
}
|
||||||
|
},
|
||||||
Err(error) => return actix_web_utils::extensions::typed_response::TypedHttpResponse::return_standard_error(401, err::MessageResource::new_from_string(error.to_string())),
|
Err(error) => return actix_web_utils::extensions::typed_response::TypedHttpResponse::return_standard_error(401, err::MessageResource::new_from_string(error.to_string())),
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
Loading…
Reference in New Issue