From 8c6fcd7fb06fcd3611a63dbaddc81c19d1f65958 Mon Sep 17 00:00:00 2001 From: philipp Date: Wed, 26 Jul 2023 08:29:22 +0200 Subject: [PATCH] only log useragent on succ login --- src/tera/auth.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/tera/auth.rs b/src/tera/auth.rs index 90edcbc..cfe294d 100644 --- a/src/tera/auth.rs +++ b/src/tera/auth.rs @@ -66,11 +66,6 @@ async fn login( cookies: &CookieJar<'_>, agent: UserAgent, ) -> Flash { - Log::create( - db, - format!("{} has this useragent: {:?}", login.name, agent), - ) - .await; let user = match User::login(db, login.name, login.password).await { Ok(user) => user, Err(LoginError::NoPasswordSet(user)) => { @@ -87,6 +82,15 @@ async fn login( let user_json: String = format!("{}", json!(user)); 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") }