diff options
Diffstat (limited to 'src/users.rs')
-rw-r--r-- | src/users.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/users.rs b/src/users.rs index 4cf9310..e8b0b67 100644 --- a/src/users.rs +++ b/src/users.rs @@ -1,12 +1,14 @@ use bcrypt::hash; use bcrypt::verify; use bcrypt::DEFAULT_COST; +use uuid::Uuid; use crate::Privacy; use crate::Result; #[derive(sqlx::FromRow)] pub struct User { + pub id: Uuid, pub username: String, pub password: String, pub email: Option<String>, @@ -19,7 +21,9 @@ pub struct User { impl User { pub fn new(username: String, password: String) -> Result<Self> { let password_hash = hash(password, DEFAULT_COST)?; + let id = Uuid::new_v4(); Ok(Self { + id, username, password: password_hash, email: None, |