feat(users): implement force set and force change password (#4564)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Apoorv Dixit
2024-05-07 19:41:24 +05:30
committed by GitHub
parent d974e6e7c2
commit 59e79ff205
25 changed files with 240 additions and 34 deletions

View File

@ -20,6 +20,7 @@ pub struct User {
pub created_at: PrimitiveDateTime,
pub last_modified_at: PrimitiveDateTime,
pub preferred_merchant_id: Option<String>,
pub last_password_modified_at: Option<PrimitiveDateTime>,
}
#[derive(
@ -35,6 +36,7 @@ pub struct UserNew {
pub created_at: Option<PrimitiveDateTime>,
pub last_modified_at: Option<PrimitiveDateTime>,
pub preferred_merchant_id: Option<String>,
pub last_password_modified_at: Option<PrimitiveDateTime>,
}
#[derive(Clone, Debug, AsChangeset, router_derive::DebugAsDisplay)]
@ -45,6 +47,7 @@ pub struct UserUpdateInternal {
is_verified: Option<bool>,
last_modified_at: PrimitiveDateTime,
preferred_merchant_id: Option<String>,
last_password_modified_at: Option<PrimitiveDateTime>,
}
#[derive(Debug)]
@ -52,10 +55,12 @@ pub enum UserUpdate {
VerifyUser,
AccountUpdate {
name: Option<String>,
password: Option<Secret<String>>,
is_verified: Option<bool>,
preferred_merchant_id: Option<String>,
},
PasswordUpdate {
password: Option<Secret<String>>,
},
}
impl From<UserUpdate> for UserUpdateInternal {
@ -68,18 +73,27 @@ impl From<UserUpdate> for UserUpdateInternal {
is_verified: Some(true),
last_modified_at,
preferred_merchant_id: None,
last_password_modified_at: None,
},
UserUpdate::AccountUpdate {
name,
password,
is_verified,
preferred_merchant_id,
} => Self {
name,
password,
password: None,
is_verified,
last_modified_at,
preferred_merchant_id,
last_password_modified_at: None,
},
UserUpdate::PasswordUpdate { password } => Self {
name: None,
password,
is_verified: None,
last_modified_at,
preferred_merchant_id: None,
last_password_modified_at: Some(last_modified_at),
},
}
}