Skip to main content

yauth_entity/
user.rs

1use chrono::NaiveDateTime;
2use serde::{Deserialize, Serialize};
3use uuid::Uuid;
4
5#[derive(Debug, Clone, Serialize, Deserialize)]
6pub struct User {
7    pub id: Uuid,
8    pub email: String,
9    pub display_name: Option<String>,
10    pub email_verified: bool,
11    pub role: String,
12    pub banned: bool,
13    pub banned_reason: Option<String>,
14    pub banned_until: Option<NaiveDateTime>,
15    pub created_at: NaiveDateTime,
16    pub updated_at: NaiveDateTime,
17}
18
19#[derive(Debug, Clone, Serialize, Deserialize)]
20pub struct NewUser {
21    pub id: Uuid,
22    pub email: String,
23    pub display_name: Option<String>,
24    pub email_verified: bool,
25    pub role: String,
26    pub banned: bool,
27    pub banned_reason: Option<String>,
28    pub banned_until: Option<NaiveDateTime>,
29    pub created_at: NaiveDateTime,
30    pub updated_at: NaiveDateTime,
31}
32
33#[derive(Debug, Clone, Default, Serialize, Deserialize)]
34pub struct UpdateUser {
35    pub email: Option<String>,
36    pub display_name: Option<Option<String>>,
37    pub email_verified: Option<bool>,
38    pub role: Option<String>,
39    pub banned: Option<bool>,
40    pub banned_reason: Option<Option<String>>,
41    pub banned_until: Option<Option<NaiveDateTime>>,
42    pub updated_at: Option<NaiveDateTime>,
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize)]
46pub struct Session {
47    pub id: Uuid,
48    pub user_id: Uuid,
49    pub token_hash: String,
50    pub ip_address: Option<String>,
51    pub user_agent: Option<String>,
52    pub expires_at: NaiveDateTime,
53    pub created_at: NaiveDateTime,
54}
55
56#[derive(Debug, Clone, Serialize, Deserialize)]
57pub struct NewSession {
58    pub id: Uuid,
59    pub user_id: Uuid,
60    pub token_hash: String,
61    pub ip_address: Option<String>,
62    pub user_agent: Option<String>,
63    pub expires_at: NaiveDateTime,
64    pub created_at: NaiveDateTime,
65}