remove jssha and add bcrypt for password hashing with salt
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import Database from 'better-sqlite3';
|
||||
import jsSHA from 'jssha';
|
||||
import bcrypt from 'bcrypt';
|
||||
|
||||
const db = new Database('./src/lib/data/tatort.db');
|
||||
|
||||
@@ -11,7 +11,8 @@ db.exec(createSQLStmt);
|
||||
|
||||
// check if there are any users; if not add one default admin one
|
||||
const userPassword = 'A-InnoHUB_2025!';
|
||||
const hashedUserPassword = new jsSHA('SHA-512', 'TEXT').update(userPassword).getHash('HEX');
|
||||
const saltRounds = 12;
|
||||
const hashedUserPassword = bcrypt.hashSync(userPassword, saltRounds);
|
||||
const checkInsertSQLStmt = `INSERT INTO users (name, pw) SELECT 'admin', '${hashedUserPassword}'
|
||||
WHERE NOT EXISTS (SELECT * FROM users);`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user