Refactor users management (#5)

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

11
Cargo.lock generated
View File

@ -438,17 +438,6 @@ dependencies = [
"syn",
]
[[package]]
name = "atty"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
"hermit-abi 0.1.19",
"libc",
"winapi",
]
[[package]]
name = "autocfg"
version = "1.1.0"

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,