-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateAdmin.js
More file actions
34 lines (29 loc) · 1001 Bytes
/
createAdmin.js
File metadata and controls
34 lines (29 loc) · 1001 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// createAdmin.js
// This code was almost entirely generated by ChatGPT (I populated the adminUser object with correct attributes)
const { PrismaClient } = require('@prisma/client');
const prisma = new PrismaClient();
const bcrypt = require('bcrypt');
async function createAdmin() {
try {
// Hash password (e.g., "admin123") - change to a secure password in production
const passwordHash = await bcrypt.hash("admin123", 10);
// Create user with admin role
const adminUser = await prisma.user.create({
data: {
firstName: "Admin",
lastName: "Pro",
email: "discordadmin@example.com",
phoneNumber: "123-456-7890",
password: passwordHash,
avatar: "/avatars/avatar1.png",
role: "ADMIN",
}
});
console.log("Admin user created:", adminUser);
} catch (error) {
console.error("Error creating admin user:", error);
} finally {
await prisma.$disconnect();
}
}
createAdmin();