mirror of
https://git.42l.fr/neil/sncf.git
synced 2024-05-19 22:26:35 +02:00
adds sncf token admin on login, fixes #28
This commit is contained in:
parent
9612086790
commit
8d6a68b33c
|
@ -145,6 +145,7 @@ pub struct CsrfToken {
|
||||||
|
|
||||||
pub async fn forward_login(
|
pub async fn forward_login(
|
||||||
req: HttpRequest,
|
req: HttpRequest,
|
||||||
|
s: Session,
|
||||||
params: web::Path<LoginToken>,
|
params: web::Path<LoginToken>,
|
||||||
client: web::Data<Client>,
|
client: web::Data<Client>,
|
||||||
dbpool: web::Data<DbPool>,
|
dbpool: web::Data<DbPool>,
|
||||||
|
@ -162,6 +163,7 @@ pub async fn forward_login(
|
||||||
crash(get_lang(&req), "error_forwardlogin_db")
|
crash(get_lang(&req), "error_forwardlogin_db")
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
let moved_token = params.token.clone();
|
||||||
// check if the link exists in DB. if it does, update lastvisit_at.
|
// check if the link exists in DB. if it does, update lastvisit_at.
|
||||||
let formdata = web::block(move || Form::get_from_token(¶ms.token, &conn))
|
let formdata = web::block(move || Form::get_from_token(¶ms.token, &conn))
|
||||||
.await
|
.await
|
||||||
|
@ -174,6 +176,12 @@ pub async fn forward_login(
|
||||||
crash(get_lang(&req), "error_forwardlogin_notfound")
|
crash(get_lang(&req), "error_forwardlogin_notfound")
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
// copy the token in cookies.
|
||||||
|
s.set("sncf_admin_token", &moved_token).map_err(|e| {
|
||||||
|
eprintln!("error_login_setcookie (in login): {}", e);
|
||||||
|
crash(get_lang(&req),"error_login_setcookie")
|
||||||
|
})?;
|
||||||
|
|
||||||
// if the user is already logged in, skip the login process
|
// if the user is already logged in, skip the login process
|
||||||
// we don't care if someone edits their cookies, Nextcloud will properly
|
// we don't care if someone edits their cookies, Nextcloud will properly
|
||||||
// check them anyway
|
// check them anyway
|
||||||
|
|
Loading…
Reference in a new issue