Hashing passwords the second
This commit is contained in:
parent
30275673bc
commit
ef2042d33c
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue