diff options
Diffstat (limited to 'server/initializers/installer.ts')
-rw-r--r-- | server/initializers/installer.ts | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/server/initializers/installer.ts b/server/initializers/installer.ts index 10b74b85f..b997de07f 100644 --- a/server/initializers/installer.ts +++ b/server/initializers/installer.ts | |||
@@ -5,6 +5,7 @@ import { database as db } from './database' | |||
5 | import { USER_ROLES, CONFIG, LAST_MIGRATION_VERSION, CACHE } from './constants' | 5 | import { USER_ROLES, CONFIG, LAST_MIGRATION_VERSION, CACHE } from './constants' |
6 | import { clientsExist, usersExist } from './checker' | 6 | import { clientsExist, usersExist } from './checker' |
7 | import { logger, createCertsIfNotExist, mkdirpPromise, rimrafPromise } from '../helpers' | 7 | import { logger, createCertsIfNotExist, mkdirpPromise, rimrafPromise } from '../helpers' |
8 | import { createUserAuthorAndChannel } from '../lib' | ||
8 | 9 | ||
9 | function installApplication () { | 10 | function installApplication () { |
10 | return db.sequelize.sync() | 11 | return db.sequelize.sync() |
@@ -91,7 +92,7 @@ function createOAuthAdminIfNotExist () { | |||
91 | const username = 'root' | 92 | const username = 'root' |
92 | const role = USER_ROLES.ADMIN | 93 | const role = USER_ROLES.ADMIN |
93 | const email = CONFIG.ADMIN.EMAIL | 94 | const email = CONFIG.ADMIN.EMAIL |
94 | const createOptions: { validate?: boolean } = {} | 95 | let validatePassword = true |
95 | let password = '' | 96 | let password = '' |
96 | 97 | ||
97 | // Do not generate a random password for tests | 98 | // Do not generate a random password for tests |
@@ -103,7 +104,7 @@ function createOAuthAdminIfNotExist () { | |||
103 | } | 104 | } |
104 | 105 | ||
105 | // Our password is weak so do not validate it | 106 | // Our password is weak so do not validate it |
106 | createOptions.validate = false | 107 | validatePassword = false |
107 | } else { | 108 | } else { |
108 | password = passwordGenerator(8, true) | 109 | password = passwordGenerator(8, true) |
109 | } | 110 | } |
@@ -115,13 +116,15 @@ function createOAuthAdminIfNotExist () { | |||
115 | role, | 116 | role, |
116 | videoQuota: -1 | 117 | videoQuota: -1 |
117 | } | 118 | } |
119 | const user = db.User.build(userData) | ||
118 | 120 | ||
119 | return db.User.create(userData, createOptions).then(createdUser => { | 121 | return createUserAuthorAndChannel(user, validatePassword) |
120 | logger.info('Username: ' + username) | 122 | .then(({ user }) => { |
121 | logger.info('User password: ' + password) | 123 | logger.info('Username: ' + username) |
124 | logger.info('User password: ' + password) | ||
122 | 125 | ||
123 | logger.info('Creating Application table.') | 126 | logger.info('Creating Application table.') |
124 | return db.Application.create({ migrationVersion: LAST_MIGRATION_VERSION }) | 127 | return db.Application.create({ migrationVersion: LAST_MIGRATION_VERSION }) |
125 | }) | 128 | }) |
126 | }) | 129 | }) |
127 | } | 130 | } |