fixed a bit

This commit is contained in:
bobbert committed 2025-03-12 01:46:32 +00:00
1 parent 25fe268ed6
commit c62413eafa
4 files changed
+60

No files matched your search

+19
View File
@@ -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;
}
BIN
View File
Binary file not shown.
+8
View File
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./*"]
}
}
}
+33
View File
@@ -0,0 +1,33 @@
import { run } from "./db.js";
async function initializeDatabase() {
try {
// Create users table
await run(`
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
username TEXT UNIQUE NOT NULL,
password TEXT NOT NULL,
role TEXT DEFAULT 'user',
team_id INTEGER,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
)
`);
// Create teams table
await run(`
CREATE TABLE IF NOT EXISTS teams (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
code TEXT UNIQUE NOT NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
)
`);
console.log("Database initialized successfully");
} catch (error) {
console.error("Database initialization error:", error);
}
}
initializeDatabase();