Skip to content

Commit c2780c0

Browse files
authored
bug fix: skip the direct api
1 parent 8ae06d6 commit c2780c0

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

src/middleware/authen_middleware.rs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,23 @@ where
6969
authenticate_pass = true;
7070
}
7171
}
72-
73-
if let Some(pool) = req.app_data::<Pool>() {
74-
info!("Connecting to database...");
75-
if let Some(authen_header) = req.headers_mut().get(constants::AUTHORIZATION) {
76-
info!("Parsing authorization header...");
77-
if let Ok(authen_str) = authen_header.to_str() {
78-
if authen_str.starts_with("bearer") || authen_str.starts_with("Bearer") {
79-
info!("Parsing token...");
80-
let token = authen_str[6..authen_str.len()].trim();
81-
if let Ok(token_data) = token_utils::decode_token(token.to_string()) {
82-
info!("Decoding token...");
83-
if token_utils::verify_token(&token_data, &pool).is_ok() {
84-
info!("Valid token");
85-
authenticate_pass = true;
86-
} else {
87-
error!("Invalid token");
72+
if !authenticate_pass {
73+
if let Some(pool) = req.app_data::<Pool>() {
74+
info!("Connecting to database...");
75+
if let Some(authen_header) = req.headers_mut().get(constants::AUTHORIZATION) {
76+
info!("Parsing authorization header...");
77+
if let Ok(authen_str) = authen_header.to_str() {
78+
if authen_str.starts_with("bearer") || authen_str.starts_with("Bearer") {
79+
info!("Parsing token...");
80+
let token = authen_str[6..authen_str.len()].trim();
81+
if let Ok(token_data) = token_utils::decode_token(token.to_string()) {
82+
info!("Decoding token...");
83+
if token_utils::verify_token(&token_data, &pool).is_ok() {
84+
info!("Valid token");
85+
authenticate_pass = true;
86+
} else {
87+
error!("Invalid token");
88+
}
8889
}
8990
}
9091
}

0 commit comments

Comments
 (0)