Skip to main content

revolt_models/v0/
mfa_tickets.rs

1auto_derived!(
2    pub struct MFATicket {
3        /// Unique Id
4        #[serde(rename = "_id")]
5        pub id: String,
6
7        /// Account Id
8        pub account_id: String,
9
10        /// Unique Token
11        pub token: String,
12
13        /// Whether this ticket has been validated
14        /// (can be used for account actions)
15        pub validated: bool,
16
17        /// Whether this ticket is authorised
18        /// (can be used to log a user in)
19        pub authorised: bool,
20
21        /// TOTP code at time of ticket creation
22        pub last_totp_code: Option<String>,
23    }
24
25    #[serde(untagged)]
26    pub enum ResponseVerify {
27        NoTicket,
28        WithTicket {
29            /// Authorised MFA ticket, can be used to log in
30            ticket: MFATicket,
31        },
32    }
33
34    /// MFA response
35    #[serde(untagged)]
36    pub enum MFAResponse {
37        Password { password: String },
38        Recovery { recovery_code: String },
39        Totp { totp_code: String },
40    }
41
42    #[derive(Default)]
43    pub struct MultiFactorStatus {
44        #[serde(skip_serializing_if = "crate::if_false", default)]
45        pub email_otp: bool,
46        #[serde(skip_serializing_if = "crate::if_false", default)]
47        pub trusted_handover: bool,
48        #[serde(skip_serializing_if = "crate::if_false", default)]
49        pub email_mfa: bool,
50        #[serde(skip_serializing_if = "crate::if_false", default)]
51        pub totp_mfa: bool,
52        #[serde(skip_serializing_if = "crate::if_false", default)]
53        pub security_key_mfa: bool,
54        #[serde(skip_serializing_if = "crate::if_false", default)]
55        pub recovery_active: bool,
56    }
57
58    pub enum MFAMethod {
59        Password,
60        Recovery,
61        Totp,
62    }
63
64    /// # Totp Secret
65    pub struct ResponseTotpSecret {
66        pub secret: String,
67    }
68);