brass/src/auth/routes.rs
2023-06-09 15:55:55 +02:00

42 lines
823 B
Rust

use actix_web::{Responder, web, HttpResponse};
use askama::Template;
use serde::Deserialize;
use crate::auth::utils::hash_plain_password;
pub fn init(cfg: &mut web::ServiceConfig) {
cfg.service(get_login);
cfg.service(post_login);
}
#[derive(Deserialize)]
struct LoginForm {
name: String,
password: String
}
#[derive(Template)]
#[template(path = "login.html")]
struct LoginTemplate {
}
#[actix_web::get("/login")]
async fn get_login() -> impl Responder {
let bla = LoginTemplate {};
HttpResponse::Ok()
.body(bla.render().unwrap())
}
#[actix_web::post("/login")]
async fn post_login(web::Form(form): web::Form<LoginForm>) -> impl Responder {
println!("{} - {}", form.name, form.password);
let hash = hash_plain_password(&form.password);
println!("{hash}");
"dfgdg"
}