This commit is contained in:
Kar
2023-05-15 14:27:10 +05:30
parent c5a98bd991
commit 02874ff761
3 changed files with 4 additions and 4 deletions

View File

@@ -7,11 +7,11 @@ const argon2 = require('argon2');
const jwt = require('jsonwebtoken');
// Connect to the SQLite database
const db = new sqlite3.Database('your_database.db');
const db = new sqlite3.Database('data/appUser.db');
// Fetch the user record
const username = 'example_user';
const sql = 'SELECT password_hash FROM user_table WHERE username = ?';
const sql = 'SELECT pass FROM user_table WHERE username = ?';
db.get(sql, [username], async (err, userRecord) => {
if (err) {
console.error(err);
@@ -28,7 +28,7 @@ db.get(sql, [username], async (err, userRecord) => {
if (isPasswordValid) {
// Passwords match, generate JWT token
const secretKey = 'your_secret_key';
const secretKey = process.env.JWT_SEC;
const tokenPayload = { username: username };
const jwtToken = jwt.sign(tokenPayload, secretKey, { algorithm: 'HS256' });