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'); const jwt = require('jsonwebtoken');
// Connect to the SQLite database // 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 // Fetch the user record
const username = 'example_user'; 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) => { db.get(sql, [username], async (err, userRecord) => {
if (err) { if (err) {
console.error(err); console.error(err);
@ -28,7 +28,7 @@ db.get(sql, [username], async (err, userRecord) => {
if (isPasswordValid) { if (isPasswordValid) {
// Passwords match, generate JWT token // Passwords match, generate JWT token
const secretKey = 'your_secret_key'; const secretKey = process.env.JWT_SEC;
const tokenPayload = { username: username }; const tokenPayload = { username: username };
const jwtToken = jwt.sign(tokenPayload, secretKey, { algorithm: 'HS256' }); const jwtToken = jwt.sign(tokenPayload, secretKey, { algorithm: 'HS256' });

View File

@ -18,6 +18,6 @@
"@/*": ["./src/*"] "@/*": ["./src/*"]
} }
}, },
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "src/pages/add-school-form.jsx", "src/pages/add-school-form.jsx", "src/pages/add-user-form.jsx", "src/pages/test/file-upload.jsx"], "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "src/pages/add-school-form.jsx", "src/pages/add-school-form.jsx", "src/pages/add-user-form.jsx", "src/pages/test/file-upload.jsx", "src/pages/user-list.jsx"],
"exclude": ["node_modules"] "exclude": ["node_modules"]
} }