torrust_index_backend/models/
user.rs

1use serde::{Deserialize, Serialize};
2
3#[allow(clippy::module_name_repetitions)]
4pub type UserId = i64;
5
6#[derive(Debug, Serialize, Deserialize, Clone, sqlx::FromRow)]
7pub struct User {
8    pub user_id: UserId,
9    pub date_registered: Option<String>,
10    pub date_imported: Option<String>,
11    pub administrator: bool,
12}
13
14#[allow(clippy::module_name_repetitions)]
15#[derive(Debug, Serialize, Deserialize, Clone, sqlx::FromRow)]
16pub struct UserAuthentication {
17    pub user_id: UserId,
18    pub password_hash: String,
19}
20
21#[allow(clippy::module_name_repetitions)]
22#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone, sqlx::FromRow)]
23pub struct UserProfile {
24    pub user_id: UserId,
25    pub username: String,
26    pub email: String,
27    pub email_verified: bool,
28    pub bio: String,
29    pub avatar: String,
30}
31
32#[allow(clippy::module_name_repetitions)]
33#[derive(Debug, Serialize, Deserialize, Clone, sqlx::FromRow)]
34pub struct UserCompact {
35    pub user_id: UserId,
36    pub username: String,
37    pub administrator: bool,
38}
39
40#[allow(clippy::module_name_repetitions)]
41#[derive(Debug, Serialize, Deserialize, Clone, sqlx::FromRow)]
42pub struct UserFull {
43    pub user_id: UserId,
44    pub date_registered: Option<String>,
45    pub date_imported: Option<String>,
46    pub administrator: bool,
47    pub username: String,
48    pub email: String,
49    pub email_verified: bool,
50    pub bio: String,
51    pub avatar: String,
52}
53
54#[allow(clippy::module_name_repetitions)]
55#[derive(Debug, Serialize, Deserialize, Clone)]
56pub struct UserClaims {
57    pub user: UserCompact,
58    pub exp: u64, // epoch in seconds
59}