97 lines
2.6 KiB
Rust
97 lines
2.6 KiB
Rust
|
use std::collections::HashMap;
|
||
|
use serde::{Deserialize,Serialize};
|
||
|
|
||
|
// use crate::defs::AppDBs;
|
||
|
|
||
|
fn default_empty() -> String {
|
||
|
"".to_string()
|
||
|
}
|
||
|
fn default_items() -> HashMap<String,String> {
|
||
|
HashMap::new()
|
||
|
}
|
||
|
fn default_expire() -> u64 {
|
||
|
300
|
||
|
}
|
||
|
fn default_send_email() -> bool {
|
||
|
false
|
||
|
}
|
||
|
fn default_isadmin() -> bool {
|
||
|
false
|
||
|
}
|
||
|
fn default_otp_empty() -> String {
|
||
|
String::from("")
|
||
|
}
|
||
|
#[derive(Default,Deserialize,Serialize,Debug,Clone)]
|
||
|
pub struct UserData {
|
||
|
#[serde(default = "default_empty")]
|
||
|
pub id: String,
|
||
|
#[serde(default = "default_empty")]
|
||
|
pub name: String,
|
||
|
#[serde(default = "default_empty")]
|
||
|
pub fullname: String,
|
||
|
#[serde(default = "default_empty")]
|
||
|
pub description: String,
|
||
|
#[serde(default = "default_empty")]
|
||
|
pub email: String,
|
||
|
#[serde(default = "default_empty")]
|
||
|
pub password: String,
|
||
|
#[serde(default = "default_otp_empty")]
|
||
|
pub otp_code: String,
|
||
|
#[serde(default = "default_otp_empty")]
|
||
|
pub otp_url: String,
|
||
|
#[serde(default = "default_otp_empty")]
|
||
|
pub otp_auth: String,
|
||
|
#[serde(default = "default_empty")]
|
||
|
pub roles: String,
|
||
|
#[serde(default = "default_items")]
|
||
|
pub items: HashMap<String,String>,
|
||
|
}
|
||
|
// impl UserData {
|
||
|
// pub fn from_id(id: String, _app_dbs: &AppDBs) -> Self {
|
||
|
// Self {
|
||
|
// id,
|
||
|
// name: String::from(""),
|
||
|
// fullname: String::from(""),
|
||
|
// description: String::from(""),
|
||
|
// email: String::from(""),
|
||
|
// password: String::from(""),
|
||
|
// roles: String::from(""),
|
||
|
// items: Vec::new()
|
||
|
// }
|
||
|
// }
|
||
|
// // pub fn contents_to_json(&self) -> Vec<String> {
|
||
|
// // self.items.clone().into_iter().map(|item| item.to_json()).collect()
|
||
|
// // }
|
||
|
//}
|
||
|
#[derive(Default,Deserialize,Serialize,Debug,Clone)]
|
||
|
pub struct UserLogin {
|
||
|
#[serde(default = "default_empty")]
|
||
|
pub name: String,
|
||
|
#[serde(default = "default_empty")]
|
||
|
pub password: String,
|
||
|
#[serde(default = "default_empty")]
|
||
|
pub otp_auth: String,
|
||
|
}
|
||
|
|
||
|
#[derive(Default,Deserialize,Serialize,Debug,Clone)]
|
||
|
pub struct UserItem {
|
||
|
#[serde(default = "default_empty")]
|
||
|
pub name: String,
|
||
|
#[serde(default = "default_empty")]
|
||
|
pub value: String,
|
||
|
}
|
||
|
|
||
|
#[derive(Default,Deserialize,Serialize,Debug,Clone)]
|
||
|
pub struct UserInvitation {
|
||
|
#[serde(default = "default_empty")]
|
||
|
pub email: String,
|
||
|
#[serde(default = "default_empty")]
|
||
|
pub roles: String,
|
||
|
#[serde(default = "default_expire")]
|
||
|
pub expire: u64,
|
||
|
#[serde(default = "default_send_email")]
|
||
|
pub send_email: bool,
|
||
|
#[serde(default = "default_isadmin")]
|
||
|
pub isadmin: bool,
|
||
|
}
|