use crate::error::Error; use crate::schema::config; use crate::schema::users; use bcrypt; #[derive(Insertable, Queryable)] #[table_name = "config"] pub struct Config { pub strava_client_secret: String, pub strava_client_id: String, pub rocket_secret_key: String, pub singleton: bool, } #[derive(Insertable, Queryable)] #[table_name = "users"] pub struct User { pub username: String, password: String, } 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 { bcrypt::verify(password, &self.password).map_err(|e| From::from(e)) } }