Continuing with the login.
This commit is contained in:
1 parent
feaab2e843
commit
5cd6d6f424
6 files changed
+241
-36
No files matched your search
@@ -12,11 +12,6 @@ use crate::services::ServiceFactory;
|
||||
use crate::util::SQLiteConnectionFactory;
|
||||
use crate::webui::MiniJinjaRenderer;
|
||||
|
||||
#[actix_web::get("/")]
|
||||
pub async fn index(tmpl_env: MiniJinjaRenderer) -> actix_web::Result<impl Responder> {
|
||||
tmpl_env.render("index.html", ())
|
||||
}
|
||||
|
||||
#[actix_web::get("/actions")]
|
||||
pub async fn actions(tmpl_env: MiniJinjaRenderer) -> actix_web::Result<impl Responder> {
|
||||
tmpl_env.render("actions.html", ())
|
||||
@@ -37,32 +32,6 @@ pub async fn overview(
|
||||
tmpl_env.render("overview.html", ctx)
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
struct LoginPayload {
|
||||
username: String,
|
||||
password: String,
|
||||
}
|
||||
|
||||
#[actix_web::post("/login")]
|
||||
pub async fn login(
|
||||
tmpl_env: MiniJinjaRenderer,
|
||||
web::Json(form): web::Json<LoginPayload>,
|
||||
) -> actix_web::Result<impl Responder> {
|
||||
let ctx = context! {
|
||||
name => form.username,
|
||||
};
|
||||
tmpl_env.render("partials/index/success.html", ctx)
|
||||
}
|
||||
|
||||
#[actix_web::post("/logout")]
|
||||
pub async fn logout(tmpl_env: MiniJinjaRenderer) -> actix_web::Result<impl Responder> {
|
||||
let ctx = context! {};
|
||||
let res = tmpl_env.render("partials/index/form.html", ctx)?;
|
||||
Ok(res
|
||||
.customize()
|
||||
.insert_header(("Set-Cookie", "username=nobody")))
|
||||
}
|
||||
|
||||
#[actix_web::get("/partials/overview/submit_button")]
|
||||
pub async fn overview_submit_button(
|
||||
_req: HttpRequest,
|
||||
|
||||
Reference in new issue
Block a user