tsx
This commit is contained in:
@@ -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' });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user