Xo/Subjects: Fix admin user creation.

This commit is contained in:
Julien Fontanet 2016-02-17 09:49:21 +01:00
parent 1a472fdf1f
commit 6f0cda34b4
2 changed files with 11 additions and 13 deletions

View File

@ -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 => {

View File

@ -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)
}
})
}
// -----------------------------------------------------------------