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
|
use serde::{Deserialize, Serialize};
use sqlx::FromRow;
use time::OffsetDateTime;
use uuid::Uuid;
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, FromRow)]
#[serde(rename_all = "camelCase")]
pub struct UserSchema {
pub uuid: Uuid,
pub name: String,
pub email: String,
#[serde(default, skip_serializing)]
pub password_hash: String,
pub session_epoch: OffsetDateTime,
pub created_at: OffsetDateTime,
pub updated_at: OffsetDateTime,
}
impl Default for UserSchema {
fn default() -> Self {
let now = time::OffsetDateTime::now_utc();
Self {
uuid: Default::default(),
name: Default::default(),
email: Default::default(),
password_hash: Default::default(),
session_epoch: now,
created_at: now,
updated_at: now,
}
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct LoginSchema {
pub email: String,
pub password: String,
}
|