uploaded
This commit is contained in:
20
admin/create-admin.js
Normal file
20
admin/create-admin.js
Normal file
@@ -0,0 +1,20 @@
|
||||
// create-admin.js
|
||||
const path = require('path');
|
||||
require('dotenv').config({ path: path.join(__dirname, '..', '.env') });
|
||||
|
||||
const bcrypt = require('bcrypt');
|
||||
const { pool } = require('../db'); // db.js is one level up
|
||||
|
||||
async function createSuperAdmin() {
|
||||
const username = 'admin_eagler';
|
||||
const password = 'ILOOyCo8zDWWNl9bOyFbtiBULrNKd9';
|
||||
const hash = await bcrypt.hash(password, 10);
|
||||
await pool.query(
|
||||
'INSERT INTO admin_users (username, password_hash, role) VALUES (?, ?, ?)',
|
||||
[username, hash, 'superadmin']
|
||||
);
|
||||
console.log('Superadmin created');
|
||||
process.exit();
|
||||
}
|
||||
|
||||
createSuperAdmin().catch(console.error);
|
||||
Reference in New Issue
Block a user