ayushman #14
2 changed files with 7 additions and 4 deletions
|
@ -42,15 +42,15 @@ import
|
|||
|
||||
"/login" -> get:
|
||||
compileTemplateFile(getScriptDir() / "view" / "login.nimja")
|
||||
"/login" -> post:
|
||||
"/htmx/login" -> post:
|
||||
var em =ctx.urlForm["email"]
|
||||
var ps=ctx.urlForm["password"]
|
||||
let conn=newTurso()
|
||||
var temp=getUser(conn, em, ps)
|
||||
if temp[0]:
|
||||
echo $(%* temp[1])
|
||||
ctx &= initCookie("user", $(%* temp[1]))
|
||||
ctx.redirect("/")
|
||||
# redirect using HX-Redict to / url
|
||||
ctx.response.headers.add("HX-Redirect", "/")
|
||||
else:
|
||||
echo "user not found"
|
||||
|
||||
|
|
|
@ -8,7 +8,10 @@
|
|||
<div class="col">
|
||||
<h1 class="mt-5">Login</h1>
|
||||
|
||||
<form id="input_form" method="post" class="" novalidate>
|
||||
<form id="input_form" class="" novalidate
|
||||
hx-trigger="submit"
|
||||
hx-post="/htmx/login"
|
||||
>
|
||||
|
||||
<label class="text-danger"></label>
|
||||
<div class="form-group mt-5">
|
||||
|
|
Loading…
Reference in a new issue