Merge pull request 'improve logging' (#1021) from improve-logging into staging

Reviewed-on: Ruderverein-Donau-Linz/rowt#1021
This commit is contained in:
philipp 2025-05-14 23:01:12 +02:00
commit 4906b757b8
2 changed files with 12 additions and 12 deletions

View File

@ -532,17 +532,19 @@ ASKÖ Ruderverein Donau Linz", self.name),
}
}
pub async fn reset_pw(&self, db: &SqlitePool) {
pub async fn reset_pw(&self, db: &SqlitePool, changed_by: &ManageUserUser) {
sqlx::query!("UPDATE user SET pw = null where id = ?", self.id)
.execute(db)
.await
.unwrap(); //Okay, because we can only create a User of a valid id
// TODO: add responsible person
ActivityBuilder::new(&format!("Passwort von User {self} wurde zurückgesetzt."))
.relevant_for_user(self)
.save(db)
.await;
ActivityBuilder::new(&format!(
"{changed_by} hat das Passwort von User {self} zurückgesetzt."
))
.relevant_for_user(self)
.save(db)
.await;
}
pub async fn update_pw(&self, db: &SqlitePool, pw: &str) {
@ -551,12 +553,10 @@ ASKÖ Ruderverein Donau Linz", self.name),
.execute(db)
.await
.unwrap(); //Okay, because we can only create a User of a valid id
ActivityBuilder::new(&format!(
"Passwort von User {self} wurde erfolgreich geändert."
))
.relevant_for_user(self)
.save(db)
.await;
ActivityBuilder::new(&format!("{self} hat sein Passwort geändert."))
.relevant_for_user(self)
.save(db)
.await;
}
fn get_hashed_pw(pw: &str) -> String {

View File

@ -276,7 +276,7 @@ async fn resetpw(db: &State<SqlitePool>, admin: ManageUserUser, user: i32) -> Fl
format!("{} has resetted the pw for {}", admin.user.name, user.name),
)
.await;
user.reset_pw(db).await;
user.reset_pw(db, &admin).await;
Flash::success(
Redirect::to("/admin/user"),
format!("Passwort von {} zurückgesetzt", user.name),