diff options
author | Kjetil Orbekk <kjetil.orbekk@gmail.com> | 2020-01-31 21:43:39 -0500 |
---|---|---|
committer | Kjetil Orbekk <kjetil.orbekk@gmail.com> | 2020-01-31 21:43:39 -0500 |
commit | 40b3e685b00f9a9f25908a85f79960913e668622 (patch) | |
tree | 3c6e3db8ebfc3ba5489bc60e8fc34329815ead7a /src/models.rs | |
parent | 2c86325e3c23fdddfb0a84e479437c8bc057a7eb (diff) |
Wipe password from user struct before returning
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, } |