Created function for htmx email and htmx password

This commit is contained in:
Harsh Singh 2024-08-15 22:21:25 +05:30
parent ee42d00896
commit 4e18308286
4 changed files with 37 additions and 28 deletions

View file

@ -12,6 +12,6 @@ bin = @["hh1"]
# Dependencies
requires "nim >= 2.0.8"
requires "https://github.com/ire4ever1190/mike >= 1.3.3"
requires "nimja"
requires "https://codeberg.org/13thab/turso-nim"
# requires "https://github.com/ire4ever1190/mike >= 1.3.3"
# requires "nimja"
# requires "https://codeberg.org/13thab/turso-nim"

28
src/controller/htmx.nim Normal file
View file

@ -0,0 +1,28 @@
import
mike,
../model/rand,
../lib/htmx
proc htmxEmail*(ctx:Context)=
var
em = ctx.urlForm["email"]
val: Validity
if em == "":
val.message = "Last Name is Required"
val.mark = "is-invalid"
else:
val.message = ""
val.mark = ""
ctx.send htmxEmail(em, val)
proc htmxPassword*(ctx:Context)=
var
pw = ctx.urlForm["password"]
val: Validity
if pw == "":
val.message = "Last Name is Required"
val.mark = "is-invalid"
else:
val.message = ""
val.mark = ""
ctx.send htmxPassword(pw, val)

View file

@ -9,7 +9,7 @@ import
./lib/[mics, htmx],
./db/users,
./model/[model, rand],
./controller/[signup, login]
./controller/[signup, login, htmx]
load()
@ -71,29 +71,9 @@ load()
"/htmx/login" -> post: ctx.htmxLogin()
"/htmx/email" -> post:
var
em = ctx.urlForm["email"]
val: Validity
if em == "":
val.message = "Last Name is Required"
val.mark = "is-invalid"
else:
val.message = ""
val.mark = ""
ctx.send htmxEmail(em, val)
"/htmx/email" -> post: htmxEmail(ctx)
"/htmx/password" -> post:
var
pw = ctx.urlForm["password"]
val: Validity
if pw == "":
val.message = "Last Name is Required"
val.mark = "is-invalid"
else:
val.message = ""
val.mark = ""
ctx.send htmxPassword(pw, val)
"/htmx/password" -> post: htmxPassword(ctx)
"/:path" -> get:
var

View file

@ -3,3 +3,4 @@ type
name*: string
message*: string
mark*: string