diff options
Diffstat (limited to 'src/models.rs')
-rw-r--r-- | src/models.rs | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/src/models.rs b/src/models.rs index 10f7d68..3b35693 100644 --- a/src/models.rs +++ b/src/models.rs @@ -1,7 +1,6 @@ use crate::error::Error; use crate::schema::config; use crate::schema::users; -use bcrypt; #[derive(Insertable, Queryable)] #[table_name = "config"] @@ -12,22 +11,15 @@ pub struct Config { pub singleton: bool, } -#[derive(Insertable, Queryable)] +#[derive(Insertable)] #[table_name = "users"] -pub struct User { - pub username: String, - password: String, +pub struct NewUser<'a> { + pub username: &'a str, + pub password: &'a str, } -impl User { - pub fn new(username: &str, password: &str) -> User { - User { - username: username.to_string(), - password: password.to_string(), - } - } - - pub fn verify(&self, password: &str) -> Result<bool, Error> { - bcrypt::verify(password, &self.password).map_err(|e| From::from(e)) - } +#[derive(Queryable)] +pub struct User { + pub username: String, + pub password: String, } |