From 3765541674a8215c474f8f51bae7ba4d89490c8b Mon Sep 17 00:00:00 2001 From: philipp Date: Tue, 25 Jul 2023 11:36:36 +0200 Subject: [PATCH] even show who's logging in --- src/model/user.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/model/user.rs b/src/model/user.rs index 905b0cf..ddd6208 100644 --- a/src/model/user.rs +++ b/src/model/user.rs @@ -148,15 +148,15 @@ ORDER BY last_access DESC } pub async fn login(db: &SqlitePool, name: &str, pw: &str) -> Result { - Log::create(db, "User '{name}' is trying to login...".into()).await; + Log::create(db, format!("User '{name}' is trying to login...").into()).await; let name = name.trim(); // just to make sure... let Some(user) = User::find_by_name(db, name).await else { - Log::create(db, "Username ({name}) not found".into()).await; + Log::create(db, format!("Username ({name}) not found").into()).await; return Err(LoginError::InvalidAuthenticationCombo); // Username not found }; if user.deleted { - Log::create(db, "User ({name}) already deleted.".into()).await; + Log::create(db, format!("User ({name}) already deleted.").into()).await; return Err(LoginError::InvalidAuthenticationCombo); //User existed sometime ago; has //been deleted } @@ -165,10 +165,10 @@ ORDER BY last_access DESC Some(user_pw) => { let password_hash = &Self::get_hashed_pw(pw); if password_hash == user_pw { - Log::create(db, "User {name} successfully logged in".into()).await; + Log::create(db, format!("User {name} successfully logged in").into()).await; return Ok(user); } - Log::create(db, "User {name} supplied the wrong PW".into()).await; + Log::create(db, format!("User {name} supplied the wrong PW").into()).await; Err(LoginError::InvalidAuthenticationCombo) } None => {