Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f920e91ec0
|
||
|
|
0b1cee5cb2
|
@@ -4,9 +4,3 @@ pub mod envy;
|
|||||||
pub mod message;
|
pub mod message;
|
||||||
pub mod token;
|
pub mod token;
|
||||||
pub mod user;
|
pub mod user;
|
||||||
|
|
||||||
pub mod init {
|
|
||||||
pub fn is_uuid_nil(uuid: &uuid::Uuid) -> bool {
|
|
||||||
uuid.is_nil()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ pub struct User {
|
|||||||
pub created: Option<time::OffsetDateTime>,
|
pub created: Option<time::OffsetDateTime>,
|
||||||
#[serde(with = "time::serde::rfc3339::option")]
|
#[serde(with = "time::serde::rfc3339::option")]
|
||||||
pub last_login: Option<time::OffsetDateTime>,
|
pub last_login: Option<time::OffsetDateTime>,
|
||||||
#[serde(skip)]
|
|
||||||
pub salt_id: uuid::Uuid,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||||
@@ -28,8 +26,6 @@ pub struct ServiceUser {
|
|||||||
// When serializing to json, if empty do not populate
|
// When serializing to json, if empty do not populate
|
||||||
#[serde(with = "time::serde::rfc3339::option")]
|
#[serde(with = "time::serde::rfc3339::option")]
|
||||||
pub last_login: Option<time::OffsetDateTime>,
|
pub last_login: Option<time::OffsetDateTime>,
|
||||||
#[serde(skip)]
|
|
||||||
pub salt_id: uuid::Uuid,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||||
@@ -69,24 +65,6 @@ pub struct UserProfile {
|
|||||||
pub last_login: Option<time::OffsetDateTime>,
|
pub last_login: Option<time::OffsetDateTime>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
|
||||||
pub struct Salt {
|
|
||||||
#[serde(skip_serializing_if = "crate::init::is_uuid_nil")]
|
|
||||||
pub id: uuid::Uuid,
|
|
||||||
#[serde(skip_serializing_if = "String::is_empty")]
|
|
||||||
pub salt: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Salt {
|
|
||||||
pub fn to_json(&self, output_pretty: bool) -> Result<String, serde_json::Error> {
|
|
||||||
if output_pretty {
|
|
||||||
serde_json::to_string_pretty(&self)
|
|
||||||
} else {
|
|
||||||
serde_json::to_string(&self)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn init_user_profile(usr: &User) -> UserProfile {
|
pub fn init_user_profile(usr: &User) -> UserProfile {
|
||||||
UserProfile {
|
UserProfile {
|
||||||
user_id: usr.id,
|
user_id: usr.id,
|
||||||
|
|||||||
Reference in New Issue
Block a user