feat: add Request/Response objects for MFA verification endpoints
This commit is contained in:
parent
317dbe1ed1
commit
530ed90171
|
@ -35,3 +35,26 @@ pub struct LoginSchema {
|
|||
pub login_source: Option<String>,
|
||||
pub gift_code_sku_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub struct VerifyMFALoginSchema {
|
||||
pub ticket: String,
|
||||
pub code: String,
|
||||
pub login_source: Option<String>,
|
||||
pub gift_code_sku_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum VerifyMFALoginResponse {
|
||||
Success { token: String, user_settings: LoginSettings },
|
||||
UserSuspended { suspended_user_token: String }
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub struct LoginSettings {
|
||||
pub locale: String,
|
||||
pub theme: String,
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
use std::fmt::Display;
|
||||
|
||||
use serde::{Serialize, Deserialize};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub struct MfaRequiredSchema {
|
||||
pub message: String,
|
||||
pub code: i32,
|
||||
pub mfa: MfaVerificationSchema,
|
||||
pub mfa: MfaVerificationSchema,
|
||||
}
|
||||
|
||||
impl Display for MfaRequiredSchema {
|
||||
|
@ -24,14 +24,14 @@ impl Display for MfaRequiredSchema {
|
|||
#[serde(rename_all = "snake_case")]
|
||||
pub struct MfaVerificationSchema {
|
||||
pub ticket: String,
|
||||
pub methods: Vec<MfaMethod>
|
||||
pub methods: Vec<MfaMethod>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub struct MfaMethod {
|
||||
#[serde(rename = "type")]
|
||||
pub kind: MfaType,
|
||||
pub kind: AuthenticatorType,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub challenge: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
|
@ -40,7 +40,7 @@ pub struct MfaMethod {
|
|||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum MfaType {
|
||||
pub enum AuthenticatorType {
|
||||
TOTP,
|
||||
SMS,
|
||||
Backup,
|
||||
|
@ -48,11 +48,27 @@ pub enum MfaType {
|
|||
Password,
|
||||
}
|
||||
|
||||
impl Display for AuthenticatorType {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{}",
|
||||
match self {
|
||||
AuthenticatorType::TOTP => "totp",
|
||||
AuthenticatorType::SMS => "sms",
|
||||
AuthenticatorType::Backup => "backup",
|
||||
AuthenticatorType::WebAuthn => "webauthn",
|
||||
AuthenticatorType::Password => "password",
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub struct MfaVerifySchema {
|
||||
pub ticket: String,
|
||||
pub mfa_type: MfaType,
|
||||
pub mfa_type: AuthenticatorType,
|
||||
pub data: String,
|
||||
}
|
||||
|
||||
|
@ -60,3 +76,13 @@ pub struct MfaVerifySchema {
|
|||
pub struct MfaTokenSchema {
|
||||
pub token: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct SendMfaSmsSchema {
|
||||
pub ticket: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct SendMfaSmsResponse {
|
||||
pub phone: String,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue