54 lines
1.1 KiB
Rust
54 lines
1.1 KiB
Rust
mod database;
|
|
mod error;
|
|
|
|
use chrono::{DateTime, Utc};
|
|
use id::UserID;
|
|
use serde::Serialize;
|
|
|
|
pub use crate::error::Error;
|
|
|
|
#[derive(Serialize, Debug, Clone)]
|
|
pub struct User {
|
|
id: UserID,
|
|
created_at: DateTime<Utc>,
|
|
updated_at: DateTime<Utc>,
|
|
is_admin: bool,
|
|
username: String,
|
|
name: Option<String>,
|
|
email: Option<String>,
|
|
password: Option<String>,
|
|
password_recover: Option<String>,
|
|
paper_key: Option<String>,
|
|
is_archived: bool,
|
|
timezone: String,
|
|
}
|
|
|
|
impl User {
|
|
pub fn id(&self) -> &UserID {
|
|
&self.id
|
|
}
|
|
pub fn is_archived(&self) -> bool {
|
|
self.is_archived
|
|
}
|
|
pub fn password_hashed(&self) -> Option<&str> {
|
|
self.password.as_deref()
|
|
}
|
|
pub fn username(&self) -> &str {
|
|
&self.username
|
|
}
|
|
pub fn name(&self) -> Option<&str> {
|
|
self.name.as_deref()
|
|
}
|
|
pub fn email(&self) -> Option<&str> {
|
|
self.email.as_deref()
|
|
}
|
|
pub fn is_admin(&self) -> bool {
|
|
self.is_admin
|
|
}
|
|
pub fn timezone(&self) -> &str {
|
|
&self.timezone
|
|
}
|
|
pub fn updated_at(&self) -> DateTime<Utc> {
|
|
self.updated_at
|
|
}
|
|
}
|