Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d907bf99a2
|
||
|
|
e5ae5e1828 | ||
|
|
179a550034 |
@@ -43,3 +43,47 @@ pub struct ServiceUserLoginHistory {
|
|||||||
pub login_time: Option<time::OffsetDateTime>,
|
pub login_time: Option<time::OffsetDateTime>,
|
||||||
pub service_user_id: uuid::Uuid,
|
pub service_user_id: uuid::Uuid,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||||
|
pub struct UserProfile {
|
||||||
|
pub user_id: uuid::Uuid,
|
||||||
|
pub phone_number: String,
|
||||||
|
pub username: String,
|
||||||
|
pub firstname: String,
|
||||||
|
pub lastname: String,
|
||||||
|
pub created: Option<time::OffsetDateTime>,
|
||||||
|
pub last_login: Option<time::OffsetDateTime>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn init_user_profile(usr: &User) -> UserProfile {
|
||||||
|
UserProfile {
|
||||||
|
user_id: usr.id,
|
||||||
|
phone_number: usr.phone_number.clone(),
|
||||||
|
username: usr.username.clone(),
|
||||||
|
firstname: usr.firstname.clone(),
|
||||||
|
lastname: usr.lastname.clone(),
|
||||||
|
created: usr.created,
|
||||||
|
last_login: usr.last_login,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
#[test]
|
||||||
|
fn test_init_user_profile() {
|
||||||
|
let usr = super::User {
|
||||||
|
id: uuid::Uuid::new_v4(),
|
||||||
|
phone_number: String::from("+12308438462"),
|
||||||
|
username: String::from("Cowboy99"),
|
||||||
|
password: String::from("238n7cyr2q89d3xhe2"),
|
||||||
|
firstname: String::from("BillyBob"),
|
||||||
|
lastname: String::from("Jones"),
|
||||||
|
created: Some(time::OffsetDateTime::now_utc()),
|
||||||
|
last_login: Some(time::OffsetDateTime::now_utc()),
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
let profile = super::init_user_profile(&usr);
|
||||||
|
assert_eq!(usr.phone_number, profile.phone_number, "Phone numbers are not equal");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user