token-as-var

This commit is contained in:
Untone 2023-10-18 13:36:28 +03:00
parent 8f236ab0dd
commit ad26023029

View File

@ -31,9 +31,12 @@ async fn connect_handler(
let token = match req.headers().get("Authorization") { let token = match req.headers().get("Authorization") {
Some(val) => val.to_str().unwrap_or("").split(" ").last().unwrap_or(""), Some(val) => val.to_str().unwrap_or("").split(" ").last().unwrap_or(""),
None => match req.match_info().get("token") { None => match req.match_info().get("token") {
Some(val) => val,
None => match req.query_string().split('=').last() {
Some(val) => val, Some(val) => val,
None => return Err(ErrorUnauthorized("Unauthorized")), None => return Err(ErrorUnauthorized("Unauthorized")),
}, },
},
}; };
let listener_id = data::get_auth_id(&token).await.map_err(|e| { let listener_id = data::get_auth_id(&token).await.map_err(|e| {