This commit is contained in:
Aritra Banik 2024-03-13 02:06:50 +05:30
parent 5a1ec3c3ee
commit 3a62312a15
4 changed files with 9 additions and 3 deletions

BIN
src/a3

Binary file not shown.

View File

@ -34,7 +34,9 @@
<span class="icon icon-person"></span> <span class="icon icon-person"></span>
</a> </a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown"> <div class="dropdown-menu" aria-labelledby="navbarDropdown">
{% if user.accessLevel >= 2 %}
<a class="dropdown-item" href="/admin/dashboard">Dashboard</a> <a class="dropdown-item" href="/admin/dashboard">Dashboard</a>
{% endif %}
<a class="dropdown-item" href="/logout">Logout</a> <a class="dropdown-item" href="/logout">Logout</a>
</div> </div>
</li> </li>

View File

@ -56,4 +56,4 @@ proc getUser*(db: DbConn, email, password: string): User =
user.password = row[4] user.password = row[4]
user.accessLevel = parseInt(row[7]) user.accessLevel = parseInt(row[7])
return user return user

View File

@ -3,12 +3,15 @@ import
segfaults, segfaults,
os, os,
nimja/parser, nimja/parser,
./a3pkg/[models, mics] ./a3pkg/[models, mics],
./a3c/users
proc index*(ctx: Context): string = proc index*(ctx: Context): string =
var var
products: seq[Products] products: seq[Products]
cookies = ctx.cookies cookies = ctx.cookies
user: User
db = newDatabase()
email = cookies.getOrDefault("email", "") email = cookies.getOrDefault("email", "")
password = cookies.getOrDefault("password", "") password = cookies.getOrDefault("password", "")
@ -17,5 +20,6 @@ proc index*(ctx: Context): string =
echo "No cookie found." echo "No cookie found."
else: else:
products = micsGetProducts(email, password) products = micsGetProducts(email, password)
user = db.getUser(email, password)
compileTemplateFile(getScriptDir() / "a3a" / "index.nimja") compileTemplateFile(getScriptDir() / "a3a" / "index.nimja")