Refactor users management (#5)

* Use asynchronous interface to clear 2FA history
This commit is contained in:
2022-11-26 14:18:46 +01:00
parent 83c4a8b27b
commit b68304c976
2 changed files with 9 additions and 16 deletions

View File

@ -111,16 +111,20 @@ pub async fn users_route(
_ => Some(Vec::new()),
};
if update.0.clear_2fa_history.is_some() {
logger.log(Action::AdminClear2FAHistory(&user));
user.last_successful_2fa = Default::default();
}
let res = users
.send(users_actor::UpdateUserRequest(user.clone()))
.await
.unwrap();
// Clear user 2FA history if requested
if update.0.clear_2fa_history.is_some() {
logger.log(Action::AdminClear2FAHistory(&user));
users
.send(users_actor::Clear2FALoginHistory(user.uid.clone()))
.await
.unwrap();
}
// If the admin requested it, reset user password
let new_password = match update.0.gen_new_password.is_some() {
false => None,