From c62413eafa1613eed0ea67505979174261575624 Mon Sep 17 00:00:00 2001 From: mudabbir-ahmad Date: Wed, 12 Mar 2025 01:46:32 +0000 Subject: [PATCH] fixed a bit --- actions/auth.js | 19 +++++++++++++++++++ database.sqlite | Bin 0 -> 24576 bytes jsconfig.json | 8 ++++++++ lib/init-db.js | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 60 insertions(+) create mode 100644 actions/auth.js create mode 100644 database.sqlite create mode 100644 jsconfig.json create mode 100644 lib/init-db.js diff --git a/actions/auth.js b/actions/auth.js new file mode 100644 index 0000000..bf0fd3b --- /dev/null +++ b/actions/auth.js @@ -0,0 +1,19 @@ +import { queryOne } from "@/lib/db"; +import bcrypt from "bcryptjs"; + +export async function validateCredentials(username, password) { + const user = await queryOne("SELECT * FROM users WHERE username = ?", [ + username, + ]); + + if (user && bcrypt.compareSync(password, user.password)) { + return { + id: user.id, + username: user.username, + role: user.role, + teamId: user.team_id, + }; + } + + return null; +} diff --git a/database.sqlite b/database.sqlite new file mode 100644 index 0000000000000000000000000000000000000000..a1ad0f13667221c4b61758ba8510e118487a839f GIT binary patch literal 24576 zcmeI&&u-H&9Kdm>YYQ4`H%<{Z-?nNK(gar|vdu#kZP#T9qS_$}t&u9V4NFq7D}SDZ zH{d~dAC5RyO4vj>>_+vq6g&Qx)Sq8+u+qzm-Zas5W@WK#BpgYHGB{x&4lajqwk+54TE zpA>ZaN}j4SFYE>KB=miAuc&Ce47~oZylJP?Xu2<4M@$zJeUn|!%my-wmw96AkzG%8 zWQ*o-tLYvbI3p`i4$buSQZL5(PPKkZsr@T3mLxi|#g=)a z9u{v^tH^eXjD!FJ2q1s}0tg_000IagfB*uUDzIHFjQ#(nhL?3AfB*srAbaru7_&kI5I_I{1Q0*~0R#|0009K} b|3A+F0tg_000IagfB*srAb