Refactor users management (#6)
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
* Improve second factor removal by admin
This commit is contained in:
@ -19,6 +19,7 @@ pub enum Action<'a> {
|
||||
AdminUpdateUser(&'a User),
|
||||
AdminDeleteUser(&'a User),
|
||||
AdminResetUserPassword(&'a User),
|
||||
AdminRemoveUserFactor(&'a User, &'a TwoFactor),
|
||||
AdminSetNewGrantedClientsList(&'a User, &'a GrantedClients),
|
||||
AdminClear2FAHistory(&'a User),
|
||||
LoginWebauthnAttempt { success: bool, user_id: UserID },
|
||||
@ -55,6 +56,11 @@ impl<'a> Action<'a> {
|
||||
user.quick_identity()
|
||||
)
|
||||
}
|
||||
Action::AdminRemoveUserFactor(user, factor) => format!(
|
||||
"removed 2 factor ({}) of user ({})",
|
||||
factor.quick_description(),
|
||||
user.quick_identity()
|
||||
),
|
||||
Action::AdminClear2FAHistory(user) => {
|
||||
format!("cleared 2FA history of {}", user.quick_identity())
|
||||
}
|
||||
@ -111,10 +117,8 @@ impl<'a> Action<'a> {
|
||||
Action::ChangedHisPassword => "changed his password".to_string(),
|
||||
Action::ClearedHisLoginHistory => "cleared his login history".to_string(),
|
||||
Action::AddNewFactor(factor) => format!(
|
||||
"added a new {} factor with name {} and id {:?} to his account",
|
||||
factor.type_str(),
|
||||
factor.name,
|
||||
factor.id,
|
||||
"added a new factor to his account : {}",
|
||||
factor.quick_description(),
|
||||
),
|
||||
Action::Removed2FAFactor { factor_id } => format!("Removed his factor {:?}", factor_id),
|
||||
}
|
||||
|
@ -45,6 +45,15 @@ pub struct TwoFactor {
|
||||
}
|
||||
|
||||
impl TwoFactor {
|
||||
pub fn quick_description(&self) -> String {
|
||||
format!(
|
||||
"#{} of type {} and name '{}'",
|
||||
self.id.0,
|
||||
self.type_str(),
|
||||
self.name
|
||||
)
|
||||
}
|
||||
|
||||
pub fn type_str(&self) -> &'static str {
|
||||
match self.kind {
|
||||
TwoFactorType::TOTP(_) => "Authenticator app",
|
||||
|
Reference in New Issue
Block a user