rive_models/
session.rs

1use crate::mfa::MFAMethod;
2use serde::Deserialize;
3
4/// Web Push subscription
5#[derive(Deserialize, Debug, Clone)]
6#[cfg_attr(feature = "schemas", derive(JsonSchema))]
7pub struct WebPushSubscription {
8    pub endpoint: String,
9    pub p256dh: String,
10    pub auth: String,
11}
12
13/// Session information
14#[derive(Deserialize, Debug, Clone)]
15pub struct Session {
16    /// Unique Id
17    #[serde(rename = "_id")]
18    pub id: String,
19    /// User Id
20    pub user_id: String,
21    /// Session token
22    pub token: String,
23    /// Display name
24    pub name: String,
25    /// Web Push subscription
26    pub subscription: Option<WebPushSubscription>,
27}
28
29/// Partial session information
30#[derive(Deserialize, Debug, Clone)]
31pub struct SessionInfo {
32    #[serde(rename = "_id")]
33    pub id: String,
34    pub name: String,
35}
36
37/// Login response
38#[derive(Deserialize, Debug, Clone)]
39#[serde(tag = "result")]
40pub enum LoginResponse {
41    Success(Session),
42    MFA {
43        ticket: String,
44        allowed_methods: Vec<MFAMethod>,
45    },
46    Disabled {
47        user_id: String,
48    },
49}