mirror of
https://git.42l.fr/neil/sncf.git
synced 2024-06-05 01:02:14 +02:00
deprecate old get/set cookie functions
This commit is contained in:
parent
1251b431a6
commit
5a521b0497
|
@ -36,23 +36,6 @@ pub fn is_logged_in(req: &HttpRequest) -> Option<&str> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn has_admintoken(req: &HttpRequest) -> Option<String> {
|
|
||||||
get_cookie(req, "sncf_admin_token")
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn has_csrftoken(req: &HttpRequest) -> Option<String> {
|
|
||||||
get_cookie(req, "sncf_csrf_cookie")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_cookie(req: &HttpRequest, cookie_name: &str) -> Option<String> {
|
|
||||||
let c = req.headers().get("Cookie")?.to_str().ok()?;
|
|
||||||
if c.contains(cookie_name) {
|
|
||||||
Some(c.to_string())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// attempts to create the account from Nextcloud's API
|
// attempts to create the account from Nextcloud's API
|
||||||
// returns the newly created username.
|
// returns the newly created username.
|
||||||
// if it fails (bad return code), returns None.
|
// if it fails (bad return code), returns None.
|
||||||
|
@ -207,8 +190,6 @@ pub async fn login(
|
||||||
str_cookiepair.push_str(&format!("{}={}; ", cookie_k, cookie_v));
|
str_cookiepair.push_str(&format!("{}={}; ", cookie_k, cookie_v));
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("SET-COOKIE: {}", str_cookiepair);
|
|
||||||
|
|
||||||
// load requesttoken regex
|
// load requesttoken regex
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref RE: Regex = Regex::new(r#"\{"token":"(?P<token>[^"]*)"\}"#)
|
static ref RE: Regex = Regex::new(r#"\{"token":"(?P<token>[^"]*)"\}"#)
|
||||||
|
|
Loading…
Reference in a new issue