fix user not found during auth

This commit is contained in:
2025-08-19 12:24:51 +02:00
parent 61363cc400
commit ef0b981d84

View File

@@ -7,7 +7,6 @@ import config from '$lib/config';
const SECRET = config.jwt.secret; const SECRET = config.jwt.secret;
const EXPIRES_IN = config.jwt.expiresIn; const EXPIRES_IN = config.jwt.expiresIn;
export function createToken(userData) { export function createToken(userData) {
return jwt.sign(userData, SECRET, { expiresIn: EXPIRES_IN }); return jwt.sign(userData, SECRET, { expiresIn: EXPIRES_IN });
} }
@@ -24,6 +23,10 @@ export function authenticate(user, password) {
const getUserSQLStmt = 'SELECT name, pw FROM users WHERE name = ?'; const getUserSQLStmt = 'SELECT name, pw FROM users WHERE name = ?';
const row = db.prepare(getUserSQLStmt).get(user); const row = db.prepare(getUserSQLStmt).get(user);
if (!row) {
return null;
}
const storedPW = row.pw; const storedPW = row.pw;
if (hashedPW && hashedPW === storedPW) { if (hashedPW && hashedPW === storedPW) {