Xo/Subjects: Fix admin user creation.
This commit is contained in:
parent
1a472fdf1f
commit
6f0cda34b4
12
src/index.js
12
src/index.js
@ -57,10 +57,6 @@ import { Strategy as LocalStrategy } from 'passport-local'
|
||||
|
||||
// ===================================================================
|
||||
|
||||
const info = (...args) => {
|
||||
console.info('[Info]', ...args)
|
||||
}
|
||||
|
||||
const warn = (...args) => {
|
||||
console.warn('[Warn]', ...args)
|
||||
}
|
||||
@ -675,14 +671,6 @@ export default async function main (args) {
|
||||
await registerPlugins(xo)
|
||||
}
|
||||
|
||||
if (!(await xo._users.exists())) {
|
||||
const email = 'admin@admin.net'
|
||||
const password = 'admin'
|
||||
|
||||
await xo.createUser(email, {password, permission: 'admin'})
|
||||
info('Default user created:', email, ' with password', password)
|
||||
}
|
||||
|
||||
// TODO: implements a timeout? (or maybe it is the services launcher
|
||||
// responsibility?)
|
||||
const shutdown = signal => {
|
||||
|
@ -46,11 +46,21 @@ export default class {
|
||||
connection: redis,
|
||||
prefix: 'xo:group'
|
||||
})
|
||||
this._users = new Users({
|
||||
const users = this._users = new Users({
|
||||
connection: redis,
|
||||
prefix: 'xo:user',
|
||||
indexes: ['email']
|
||||
})
|
||||
|
||||
xo.on('starting', async () => {
|
||||
if (!(await users.exists())) {
|
||||
const email = 'admin@admin.net'
|
||||
const password = 'admin'
|
||||
|
||||
await this.createUser(email, {password, permission: 'admin'})
|
||||
console.log('[INFO] Default user created:', email, ' with password', password)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user