only log useragent on succ login

This commit is contained in:
philipp 2023-07-26 08:29:22 +02:00
parent aa70c61478
commit 8c6fcd7fb0

View File

@ -66,11 +66,6 @@ async fn login(
cookies: &CookieJar<'_>, cookies: &CookieJar<'_>,
agent: UserAgent, agent: UserAgent,
) -> Flash<Redirect> { ) -> Flash<Redirect> {
Log::create(
db,
format!("{} has this useragent: {:?}", login.name, agent),
)
.await;
let user = match User::login(db, login.name, login.password).await { let user = match User::login(db, login.name, login.password).await {
Ok(user) => user, Ok(user) => user,
Err(LoginError::NoPasswordSet(user)) => { Err(LoginError::NoPasswordSet(user)) => {
@ -87,6 +82,15 @@ async fn login(
let user_json: String = format!("{}", json!(user)); let user_json: String = format!("{}", json!(user));
cookies.add_private(Cookie::new("loggedin_user", user_json)); cookies.add_private(Cookie::new("loggedin_user", user_json));
Log::create(
db,
format!(
"Succ login of {} with this useragent: {:?}",
login.name, agent
),
)
.await;
Flash::success(Redirect::to("/"), "Login erfolgreich") Flash::success(Redirect::to("/"), "Login erfolgreich")
} }