mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-11 03:24:16 +00:00
fix setup script
This commit is contained in:
parent
6a208d15be
commit
03f9fe0b47
@ -1,24 +1,25 @@
|
|||||||
import { User } from "../../models"
|
import { User } from "../../models"
|
||||||
import { createUser } from "../../lib"
|
import createUser from "../../controllers/UserController/methods/createUser"
|
||||||
|
|
||||||
export default async () => {
|
export default async () => {
|
||||||
// check if any user with includes admin role exists
|
// check if any user with includes admin role exists
|
||||||
const adminUser = await User.find({
|
const adminUser = await User.find({
|
||||||
$or: [
|
$or: [
|
||||||
{ roles: { $in: ['admin'] } },
|
{ roles: { $in: ["admin"] } },
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
// if no user with admin role exists, create one
|
// if no user with admin role exists, create one
|
||||||
if (adminUser.length === 0) {
|
if (adminUser.length === 0) {
|
||||||
console.log('Creating admin user...')
|
console.log("Creating admin user...")
|
||||||
|
|
||||||
await createUser({
|
await createUser({
|
||||||
username: 'admin',
|
username: "admin",
|
||||||
password: 'admin',
|
password: "admin",
|
||||||
roles: ['admin'],
|
email: "admin@admin.com",
|
||||||
|
roles: ["admin"],
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log('Admin user created!')
|
console.log("Admin user created!")
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user