File size: 798 Bytes
42f3cc1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | const mongoose = require('mongoose');
const argon2 = require('argon2');
require('dotenv').config();
const UserSchema = new mongoose.Schema({
username: String, email: String, password: String, role: String,
activation: { isActive: Boolean, plan: String, renderQuota: Number }
});
const User = mongoose.model('User', UserSchema);
async function createAdmin() {
await mongoose.connect(process.env.MONGODB_URI || 'mongodb://localhost:27017/okid_db');
const admin = new User({
username: 'admin',
email: 'admin@example.com',
password: await argon2.hash('Admin123!'),
role: 'admin',
activation: { isActive: true, plan: 'unlimited', renderQuota: 999999 }
});
await admin.save();
console.log('Admin user created');
process.exit(0);
}
createAdmin().catch(console.error); |