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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
extern crate argonautica;
use serde::{Deserialize, Serialize};
mod extractors;
pub use extractors::*;
pub mod controller;
mod endpoints;
pub use endpoints::*;
mod mail;
mod permissions;
mod schema;
mod user;
mod user_session;
pub use permissions::{
Permission, Role, RolePermission, RolePermissionChangeset, UserPermission,
UserPermissionChangeset,
};
pub use user::{User, UserChangeset};
pub use user_session::{UserSession, UserSessionChangeset};
#[tsync::tsync]
type ID = i32;
#[tsync::tsync]
#[cfg(not(feature = "database_sqlite"))]
type UTC = chrono::DateTime<chrono::Utc>;
#[cfg(feature = "database_sqlite")]
type UTC = chrono::NaiveDateTime;
#[tsync::tsync]
#[derive(Deserialize)]
pub struct PaginationParams {
pub page: i64,
pub page_size: i64,
}
impl PaginationParams {
const MAX_PAGE_SIZE: u16 = 100;
}
#[tsync::tsync]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct UserSessionJson {
pub id: ID,
pub device: Option<String>,
pub created_at: UTC,
#[cfg(not(feature = "database_sqlite"))]
pub updated_at: UTC,
}
#[tsync::tsync]
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct UserSessionResponse {
pub sessions: Vec<UserSessionJson>,
pub num_pages: i64,
}
#[tsync::tsync]
#[derive(Debug, Serialize, Deserialize)]
pub struct AccessTokenClaims {
pub exp: usize,
pub sub: ID,
pub token_type: String,
pub roles: Vec<String>,
pub permissions: Vec<Permission>,
}