1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
use iso8601_timestamp::Timestamp;
use crate::v0::{MFAMethod, MFAResponse};
auto_derived!(
pub struct Session {
/// Unique Id
#[serde(rename = "_id")]
pub id: String,
/// User Id
pub user_id: String,
/// Session token
pub token: String,
/// Display name
pub name: String,
/// When the session was last logged in
pub last_seen: Timestamp,
/// Where the session is originating from
#[serde(skip_serializing_if = "Option::is_none")]
pub origin: Option<String>,
/// Web Push subscription
#[serde(skip_serializing_if = "Option::is_none")]
pub subscription: Option<WebPushSubscription>,
}
/// Web Push subscription
pub struct WebPushSubscription {
pub endpoint: String,
pub p256dh: String,
pub auth: String,
}
/// # Edit Data
pub struct DataEditSession {
/// Session friendly name
pub friendly_name: String,
}
pub struct SessionInfo {
#[serde(rename = "_id")]
pub id: String,
pub name: String,
}
/// # Login Data
#[serde(untagged)]
pub enum DataLogin {
Email {
/// Email
email: String,
/// Password
password: String,
/// Friendly name used for the session
friendly_name: Option<String>,
},
MFA {
/// Unvalidated or authorised MFA ticket
///
/// Used to resolve the correct account
mfa_ticket: String,
/// Valid MFA response
///
/// This will take precedence over the `password` field where applicable
mfa_response: Option<MFAResponse>,
/// Friendly name used for the session
friendly_name: Option<String>,
},
}
#[serde(tag = "result")]
pub enum ResponseLogin {
Success(Session),
MFA {
ticket: String,
allowed_methods: Vec<MFAMethod>,
},
Disabled {
user_id: String,
},
}
);