feat(admin): create and list users commands
This commit is contained in:
parent
8d20cab18f
commit
a0de3b287b
19 changed files with 314 additions and 30 deletions
|
|
@ -2,6 +2,8 @@ use fully_pub::fully_pub;
|
|||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::types::Json;
|
||||
use utils::get_random_human_token;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(sqlx::Type, Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[derive(strum_macros::Display)]
|
||||
|
|
@ -30,3 +32,30 @@ struct User {
|
|||
last_login_at: Option<DateTime<Utc>>,
|
||||
created_at: DateTime<Utc>
|
||||
}
|
||||
|
||||
impl User {
|
||||
pub fn new(
|
||||
handle: String
|
||||
) -> User {
|
||||
User {
|
||||
id: Uuid::new_v4().to_string(),
|
||||
handle,
|
||||
full_name: None,
|
||||
email: None,
|
||||
website: None,
|
||||
picture: None,
|
||||
password_hash: None,
|
||||
status: UserStatus::Disabled,
|
||||
roles: Json(Vec::new()),
|
||||
reset_password_token: None,
|
||||
last_login_at: None,
|
||||
created_at: Utc::now()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn invite(self: &mut Self) {
|
||||
self.reset_password_token = Some(get_random_human_token());
|
||||
self.status = UserStatus::Invited;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue