compiling state [wip]
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
extern crate bcrypt;
|
||||
|
||||
use bcrypt::{hash, DEFAULT_COST};
|
||||
use diesel::Insertable;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::schema::users;
|
||||
|
||||
#[derive(Insertable, Clone)]
|
||||
#[diesel(table_name=users)]
|
||||
pub struct NewUser {
|
||||
pub username: String,
|
||||
pub email: String,
|
||||
pub password: String,
|
||||
pub unique_id: String,
|
||||
}
|
||||
|
||||
impl NewUser {
|
||||
pub fn new(username: String, email: String, password: String) -> NewUser {
|
||||
let hashed_password: String = hash(password.as_str(), DEFAULT_COST).unwrap();
|
||||
let uuid = Uuid::new_v4();
|
||||
NewUser {
|
||||
username,
|
||||
email,
|
||||
password: hashed_password,
|
||||
unique_id: uuid.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user