rive_models/
mfa.rs

1use serde::{Deserialize, Serialize};
2
3/// MFA request/response data
4#[derive(Serialize, Deserialize, Debug, Clone)]
5#[serde(untagged)]
6pub enum MFAData {
7    Password { password: String },
8    Recovery { recovery_code: String },
9    Totp { totp_code: String },
10}
11
12/// MFA method
13#[derive(Deserialize, Debug, Clone, Eq, PartialEq)]
14pub enum MFAMethod {
15    Password,
16    Recovery,
17    Totp,
18}
19
20/// MFA recovery code
21pub type MFARecoveryCode = String;
22
23/// MFA status
24#[derive(Deserialize, Debug, Clone)]
25pub struct MFAStatus {
26    pub email_otp: bool,
27    pub trusted_handover: bool,
28    pub email_mfa: bool,
29    pub totp_mfa: bool,
30    pub security_key_mfa: bool,
31    pub recovery_active: bool,
32}
33
34/// TOTP secret response
35#[derive(Deserialize, Debug, Clone)]
36pub struct TOTPSecret {
37    pub secret: String,
38}
39
40/// Multi-factor auth ticket
41#[derive(Deserialize, Debug, Clone)]
42pub struct MFATicket {
43    /// Unique Id
44    #[serde(rename = "_id")]
45    pub id: String,
46
47    /// Account Id
48    pub account_id: String,
49
50    /// Unique Token
51    pub token: String,
52
53    /// Whether this ticket has been validated
54    /// (can be used for account actions)
55    pub validated: bool,
56
57    /// Whether this ticket is authorised
58    /// (can be used to log a user in)
59    pub authorised: bool,
60
61    /// TOTP code at time of ticket creation
62    pub last_totp_code: Option<String>,
63}