This commit is contained in:
cereci5049 2024-07-20 20:01:35 +05:30
parent d91f90cb45
commit 5b37a8509b
5 changed files with 36 additions and 6 deletions

View file

@ -3,7 +3,7 @@ import
strformat,
json,
strutils,
../models/models
../model/model
proc setupUsers*(conn: Turso) =
conn.execute("""

BIN
src/hh1 Executable file

Binary file not shown.

View file

@ -1,9 +1,13 @@
import
mike,
nimja,
strutils
strutils,
json,
./lib/mics,
./db/users,
./model/model
"/" -> get:
"/" -> [get, post]:
compileTemplateFile(getScriptDir() / "view" / "index.nimja")
"/shop" -> get:
@ -27,6 +31,30 @@ import
"/signup" -> get:
compileTemplateFile(getScriptDir() / "view" / "signup.nimja")
"/signup" -> post:
var
firstName = ctx.urlForm["fn"]
lastName = ctx.urlForm["ln"]
email = ctx.urlForm["em"]
password = ctx.urlForm["pw"]
conn = newTurso()
echo firstName, lastName, email, password
if firstName.len == 0 or lastName.len == 0 or email.len == 0 or password.len == 0:
ctx.send(parseJson("""{"ok": false, "failure": "Missing parameters"}"""))
else:
var user = User(
firstName: firstName,
lastName: lastName,
email: email,
password: password,
accessLevel: 1
)
conn.createPost(user)
ctx.redirect("/")
"/login" -> get:
compileTemplateFile(getScriptDir() / "view" / "login.nimja")

0
src/lib/htmx.nim Normal file
View file

View file

@ -1,14 +1,16 @@
{% extends "view/partials/_master.nimja" %}
{% block spheader1 %} Sign Up {% endblock %}
{% block spheader2 %} Sign Up {% endblock %}
{% block content %}
<div class="container">
<div class="row">
<div class="col">
<h1 class="mt-5">Login</h1>
<h1 class="mt-5">Sign Up</h1>
<form id="input_form" method="POST" class="" novalidate>
<form id="input_form" method="post" class="" novalidate>
{# <!-- <label class="text-danger">{{loginError}}</label> --> #}
<label class="text-danger"></label>
@ -67,7 +69,7 @@
<hr>
<button id="b4" class="btn btn-primary" type="submit">Submit</button>
<button id="b4" type="submit" class="btn btn-primary">Submit</button>
<a id="b4" href="/login" class="btn btn-outline-primary">Login</a>
<hr>
</form>