mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 03:13:56 +08:00
feat(users): setup user authentication methods schema and apis (#4999)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Co-authored-by: Mani Chandra Dulam <mani.dchandra@juspay.in>
This commit is contained in:
65
crates/diesel_models/src/user_authentication_method.rs
Normal file
65
crates/diesel_models/src/user_authentication_method.rs
Normal file
@ -0,0 +1,65 @@
|
||||
use diesel::{AsChangeset, Identifiable, Insertable, Queryable};
|
||||
use time::PrimitiveDateTime;
|
||||
|
||||
use crate::{encryption::Encryption, enums, schema::user_authentication_methods};
|
||||
|
||||
#[derive(Clone, Debug, Identifiable, Queryable)]
|
||||
#[diesel(table_name = user_authentication_methods)]
|
||||
pub struct UserAuthenticationMethod {
|
||||
pub id: String,
|
||||
pub auth_id: String,
|
||||
pub owner_id: String,
|
||||
pub owner_type: enums::Owner,
|
||||
pub auth_type: enums::UserAuthType,
|
||||
pub private_config: Option<Encryption>,
|
||||
pub public_config: Option<serde_json::Value>,
|
||||
pub allow_signup: bool,
|
||||
pub created_at: PrimitiveDateTime,
|
||||
pub last_modified_at: PrimitiveDateTime,
|
||||
}
|
||||
|
||||
#[derive(router_derive::Setter, Clone, Debug, Insertable, router_derive::DebugAsDisplay)]
|
||||
#[diesel(table_name = user_authentication_methods)]
|
||||
pub struct UserAuthenticationMethodNew {
|
||||
pub id: String,
|
||||
pub auth_id: String,
|
||||
pub owner_id: String,
|
||||
pub owner_type: enums::Owner,
|
||||
pub auth_type: enums::UserAuthType,
|
||||
pub private_config: Option<Encryption>,
|
||||
pub public_config: Option<serde_json::Value>,
|
||||
pub allow_signup: bool,
|
||||
pub created_at: PrimitiveDateTime,
|
||||
pub last_modified_at: PrimitiveDateTime,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, AsChangeset, router_derive::DebugAsDisplay)]
|
||||
#[diesel(table_name = user_authentication_methods)]
|
||||
pub struct OrgAuthenticationMethodUpdateInternal {
|
||||
pub private_config: Option<Encryption>,
|
||||
pub public_config: Option<serde_json::Value>,
|
||||
pub last_modified_at: PrimitiveDateTime,
|
||||
}
|
||||
|
||||
pub enum UserAuthenticationMethodUpdate {
|
||||
UpdateConfig {
|
||||
private_config: Option<Encryption>,
|
||||
public_config: Option<serde_json::Value>,
|
||||
},
|
||||
}
|
||||
|
||||
impl From<UserAuthenticationMethodUpdate> for OrgAuthenticationMethodUpdateInternal {
|
||||
fn from(value: UserAuthenticationMethodUpdate) -> Self {
|
||||
let last_modified_at = common_utils::date_time::now();
|
||||
match value {
|
||||
UserAuthenticationMethodUpdate::UpdateConfig {
|
||||
private_config,
|
||||
public_config,
|
||||
} => Self {
|
||||
private_config,
|
||||
public_config,
|
||||
last_modified_at,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user