uploaded
This commit is contained in:
18
admin/server/create-admin.js
Normal file
18
admin/server/create-admin.js
Normal file
@@ -0,0 +1,18 @@
|
||||
// create-admin.js
|
||||
require('dotenv').config();
|
||||
const bcrypt = require('bcrypt');
|
||||
const { pool } = require('./db');
|
||||
|
||||
async function createSuperAdmin() {
|
||||
const username = 'admin'; // change as needed
|
||||
const password = 'your-strong-password';
|
||||
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