fix user not found during auth
This commit is contained in:
@@ -7,7 +7,6 @@ import config from '$lib/config';
|
||||
const SECRET = config.jwt.secret;
|
||||
const EXPIRES_IN = config.jwt.expiresIn;
|
||||
|
||||
|
||||
export function createToken(userData) {
|
||||
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 row = db.prepare(getUserSQLStmt).get(user);
|
||||
|
||||
if (!row) {
|
||||
return null;
|
||||
}
|
||||
const storedPW = row.pw;
|
||||
|
||||
if (hashedPW && hashedPW === storedPW) {
|
||||
|
||||
Reference in New Issue
Block a user