diff options
Diffstat (limited to 'server/initializers/installer.js')
-rw-r--r-- | server/initializers/installer.js | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/server/initializers/installer.js b/server/initializers/installer.js index 32830d4da..1df300ba8 100644 --- a/server/initializers/installer.js +++ b/server/initializers/installer.js | |||
@@ -9,14 +9,16 @@ const path = require('path') | |||
9 | const series = require('async/series') | 9 | const series = require('async/series') |
10 | 10 | ||
11 | const checker = require('./checker') | 11 | const checker = require('./checker') |
12 | const constants = require('./constants') | ||
12 | const logger = require('../helpers/logger') | 13 | const logger = require('../helpers/logger') |
13 | const peertubeCrypto = require('../helpers/peertube-crypto') | 14 | const peertubeCrypto = require('../helpers/peertube-crypto') |
14 | 15 | ||
16 | const Application = mongoose.model('Application') | ||
15 | const Client = mongoose.model('OAuthClient') | 17 | const Client = mongoose.model('OAuthClient') |
16 | const User = mongoose.model('User') | 18 | const User = mongoose.model('User') |
17 | 19 | ||
18 | const installer = { | 20 | const installer = { |
19 | installApplication: installApplication | 21 | installApplication |
20 | } | 22 | } |
21 | 23 | ||
22 | function installApplication (callback) { | 24 | function installApplication (callback) { |
@@ -34,7 +36,7 @@ function installApplication (callback) { | |||
34 | }, | 36 | }, |
35 | 37 | ||
36 | function createOAuthUser (callbackAsync) { | 38 | function createOAuthUser (callbackAsync) { |
37 | createOAuthUserIfNotExist(callbackAsync) | 39 | createOAuthAdminIfNotExist(callbackAsync) |
38 | } | 40 | } |
39 | ], callback) | 41 | ], callback) |
40 | } | 42 | } |
@@ -80,7 +82,7 @@ function createOAuthClientIfNotExist (callback) { | |||
80 | }) | 82 | }) |
81 | } | 83 | } |
82 | 84 | ||
83 | function createOAuthUserIfNotExist (callback) { | 85 | function createOAuthAdminIfNotExist (callback) { |
84 | checker.usersExist(function (err, exist) { | 86 | checker.usersExist(function (err, exist) { |
85 | if (err) return callback(err) | 87 | if (err) return callback(err) |
86 | 88 | ||
@@ -90,6 +92,7 @@ function createOAuthUserIfNotExist (callback) { | |||
90 | logger.info('Creating the administrator.') | 92 | logger.info('Creating the administrator.') |
91 | 93 | ||
92 | const username = 'root' | 94 | const username = 'root' |
95 | const role = constants.USER_ROLES.ADMIN | ||
93 | let password = '' | 96 | let password = '' |
94 | 97 | ||
95 | // Do not generate a random password for tests | 98 | // Do not generate a random password for tests |
@@ -104,17 +107,20 @@ function createOAuthUserIfNotExist (callback) { | |||
104 | } | 107 | } |
105 | 108 | ||
106 | const user = new User({ | 109 | const user = new User({ |
107 | username: username, | 110 | username, |
108 | password: password | 111 | password, |
112 | role | ||
109 | }) | 113 | }) |
110 | 114 | ||
111 | user.save(function (err, createdUser) { | 115 | user.save(function (err, createdUser) { |
112 | if (err) return callback(err) | 116 | if (err) return callback(err) |
113 | 117 | ||
114 | logger.info('Username: ' + createdUser.username) | 118 | logger.info('Username: ' + username) |
115 | logger.info('User password: ' + createdUser.password) | 119 | logger.info('User password: ' + password) |
116 | 120 | ||
117 | return callback(null) | 121 | logger.info('Creating Application collection.') |
122 | const application = new Application({ mongoSchemaVersion: constants.LAST_MONGO_SCHEMA_VERSION }) | ||
123 | application.save(callback) | ||
118 | }) | 124 | }) |
119 | }) | 125 | }) |
120 | } | 126 | } |