Refactor users management ()

* Improve deletion of 2FA factors
This commit is contained in:
2022-11-19 18:35:41 +01:00
parent ec2f271ed4
commit e739b10065
4 changed files with 27 additions and 11 deletions

@ -9,7 +9,7 @@ use crate::constants::MAX_SECOND_FACTOR_NAME_LEN;
use crate::data::action_logger::{Action, ActionLogger};
use crate::data::current_user::CurrentUser;
use crate::data::totp_key::TotpKey;
use crate::data::user::{FactorID, TwoFactor, TwoFactorType, User};
use crate::data::user::{FactorID, TwoFactor, TwoFactorType};
use crate::data::webauthn_manager::WebAuthManagerReq;
fn preprocess_factor_name(name: &str) -> String {
@ -125,11 +125,11 @@ pub async fn delete_factor(
users: web::Data<Addr<UsersActor>>,
logger: ActionLogger,
) -> impl Responder {
let mut user = User::from(user);
user.remove_factor(form.0.id.clone());
let res = users
.send(users_actor::UpdateUserRequest(user))
.send(users_actor::Remove2FAFactor(
user.uid.clone(),
form.id.clone(),
))
.await
.unwrap();