forked from Txio-labs/txio-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathotp.rs
More file actions
26 lines (24 loc) · 616 Bytes
/
Copy pathotp.rs
File metadata and controls
26 lines (24 loc) · 616 Bytes
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
use chrono::{DateTime, Utc};
use mongodb::bson::oid::ObjectId;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct OTP {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub id: Option<ObjectId>,
pub email: String,
pub otp: String,
#[serde(default)]
pub failed_attempts: i32,
pub created_at: DateTime<Utc>,
}
impl OTP {
pub fn new(email: String, otp: String) -> Self {
Self {
id: None,
email,
otp,
failed_attempts: 0,
created_at: Utc::now(),
}
}
}