renaming pw to vorgangPIN, case to vorgang, password to vorgangToken

This commit is contained in:
2025-07-25 14:21:23 +02:00
parent 52e9eba7ed
commit 08d83c9ed4
26 changed files with 2052 additions and 219 deletions

View File

@@ -1,6 +1,5 @@
import jwt from 'jsonwebtoken';
import jsSHA from 'jssha';
import process from 'process';
import { db } from '$lib/server/dbService';
import config from '$lib/config';
@@ -8,7 +7,6 @@ import config from '$lib/config';
const SECRET = config.jwt.secret;
const EXPIRES_IN = config.jwt.expiresIn;
const AUTH = config.auth;
export function createToken(userData) {
return jwt.sign(userData, SECRET, { expiresIn: EXPIRES_IN });
@@ -18,15 +16,15 @@ export function decryptToken(token: string) {
return jwt.verify(token, SECRET);
}
export function authenticate(user, pass) {
export function authenticate(user, password) {
let JWTToken;
// hash user password
let hashedPW = new jsSHA('SHA-512', 'TEXT').update(pass).getHash('HEX');
const hashedPW = new jsSHA('SHA-512', 'TEXT').update(password).getHash('HEX');
let getUserSQLStmt = 'SELECT name, pw FROM users WHERE name = ?';
const getUserSQLStmt = 'SELECT name, pw FROM users WHERE name = ?';
const row = db.prepare(getUserSQLStmt).get(user);
let storedPW = row.pw;
const storedPW = row.pw;
if (hashedPW && hashedPW === storedPW) {
JWTToken = createToken({ id: user, admin: true });