mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-11 03:24:16 +00:00
added server setup scripts
This commit is contained in:
parent
00b125f575
commit
0b3619e901
24
packages/server/src/setup/dbAdmin/index.js
Normal file
24
packages/server/src/setup/dbAdmin/index.js
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import { User } from "../../models"
|
||||||
|
import { createUser } from "../../lib"
|
||||||
|
|
||||||
|
export default async () => {
|
||||||
|
// check if any user with includes admin role exists
|
||||||
|
const adminUser = await User.find({
|
||||||
|
$or: [
|
||||||
|
{ roles: { $in: ['admin'] } },
|
||||||
|
],
|
||||||
|
})
|
||||||
|
|
||||||
|
// if no user with admin role exists, create one
|
||||||
|
if (adminUser.length === 0) {
|
||||||
|
console.log('Creating admin user...')
|
||||||
|
|
||||||
|
await createUser({
|
||||||
|
username: 'admin',
|
||||||
|
password: 'admin',
|
||||||
|
roles: ['admin'],
|
||||||
|
})
|
||||||
|
|
||||||
|
console.log('Admin user created!')
|
||||||
|
}
|
||||||
|
}
|
6
packages/server/src/setup/index.js
Normal file
6
packages/server/src/setup/index.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import { default as dbAdmin } from "./dbAdmin"
|
||||||
|
|
||||||
|
// set here the setup functions
|
||||||
|
export default [
|
||||||
|
dbAdmin,
|
||||||
|
]
|
Loading…
x
Reference in New Issue
Block a user