tsx
parent
c5a98bd991
commit
02874ff761
|
@ -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' });
|
||||
|
||||
|
|
|
@ -18,6 +18,6 @@
|
|||
"@/*": ["./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"]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue