use iso8601_timestamp::Timestamp;
use super::MultiFactorAuthentication;
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(tag = "status")]
pub enum EmailVerification {
Verified,
Pending { token: String, expiry: Timestamp },
Moving {
new_email: String,
token: String,
expiry: Timestamp,
},
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct PasswordReset {
pub token: String,
pub expiry: Timestamp,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(tag = "status")]
pub enum DeletionInfo {
WaitingForVerification { token: String, expiry: Timestamp },
Scheduled { after: Timestamp },
Deleted,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Lockout {
pub attempts: i32,
pub expiry: Option<Timestamp>,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Account {
#[serde(rename = "_id")]
pub id: String,
pub email: String,
pub email_normalised: String,
pub password: String,
#[serde(default)]
pub disabled: bool,
pub verification: EmailVerification,
pub password_reset: Option<PasswordReset>,
pub deletion: Option<DeletionInfo>,
pub lockout: Option<Lockout>,
pub mfa: MultiFactorAuthentication,
}