Hashing passwords the second

This commit is contained in:
famfo 2022-05-11 11:12:38 +02:00
parent 30275673bc
commit ef2042d33c
2 changed files with 12 additions and 1 deletions

View file

@ -82,10 +82,20 @@ impl Database {
pub async fn register(&self, username: &str, password: &str) {
let hash = self.hash(password);
if let Err(ref e) = hash {
if let Err(_) = hash {
return;
}
tracing::debug!("{}", hash.unwrap());
// TODO: insert into DB
}
pub async fn login(&self, username: &str, password: &str) {
let hash = self.hash(password);
if let Err(_) = hash {
return;
}
tracing::debug!("{}", hash.unwrap());
// TODO: find user in DB and check if the password matches
// TODO: save that the user is logged in a cookie or something
}
}

View file

@ -104,6 +104,7 @@ async fn sort_task(req: web::Form<task::SortTask>, db: web::Data<Arc<Database>>)
async fn login_user(req: web::Form<task::Login>, db: web::Data<Arc<Database>>) -> impl Responder {
tracing::debug!("Got POST request on /api/login");
db.login(&req.username, &req.password).await;
HttpResponse::SeeOther().insert_header(("Location", "/task")).finish()
}