aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers
diff options
context:
space:
mode:
Diffstat (limited to 'server/initializers')
-rw-r--r--server/initializers/constants.js8
-rw-r--r--server/initializers/installer.js9
2 files changed, 13 insertions, 4 deletions
diff --git a/server/initializers/constants.js b/server/initializers/constants.js
index 5f4aeccc6..416356400 100644
--- a/server/initializers/constants.js
+++ b/server/initializers/constants.js
@@ -72,6 +72,11 @@ const THUMBNAILS_SIZE = '200x110'
72// Path for access to thumbnails with express router 72// Path for access to thumbnails with express router
73const THUMBNAILS_STATIC_PATH = '/static/thumbnails' 73const THUMBNAILS_STATIC_PATH = '/static/thumbnails'
74 74
75const USER_ROLES = {
76 ADMIN: 'admin',
77 USER: 'user'
78}
79
75// Special constants for a test instance 80// Special constants for a test instance
76if (isTestInstance() === true) { 81if (isTestInstance() === true) {
77 FRIEND_SCORE.BASE = 20 82 FRIEND_SCORE.BASE = 20
@@ -96,7 +101,8 @@ module.exports = {
96 SEEDS_IN_PARALLEL: SEEDS_IN_PARALLEL, 101 SEEDS_IN_PARALLEL: SEEDS_IN_PARALLEL,
97 SORTABLE_COLUMNS: SORTABLE_COLUMNS, 102 SORTABLE_COLUMNS: SORTABLE_COLUMNS,
98 THUMBNAILS_SIZE: THUMBNAILS_SIZE, 103 THUMBNAILS_SIZE: THUMBNAILS_SIZE,
99 THUMBNAILS_STATIC_PATH: THUMBNAILS_STATIC_PATH 104 THUMBNAILS_STATIC_PATH: THUMBNAILS_STATIC_PATH,
105 USER_ROLES: USER_ROLES
100} 106}
101 107
102// --------------------------------------------------------------------------- 108// ---------------------------------------------------------------------------
diff --git a/server/initializers/installer.js b/server/initializers/installer.js
index 32830d4da..c12187871 100644
--- a/server/initializers/installer.js
+++ b/server/initializers/installer.js
@@ -9,6 +9,7 @@ const path = require('path')
9const series = require('async/series') 9const series = require('async/series')
10 10
11const checker = require('./checker') 11const checker = require('./checker')
12const constants = require('./constants')
12const logger = require('../helpers/logger') 13const logger = require('../helpers/logger')
13const peertubeCrypto = require('../helpers/peertube-crypto') 14const peertubeCrypto = require('../helpers/peertube-crypto')
14 15
@@ -34,7 +35,7 @@ function installApplication (callback) {
34 }, 35 },
35 36
36 function createOAuthUser (callbackAsync) { 37 function createOAuthUser (callbackAsync) {
37 createOAuthUserIfNotExist(callbackAsync) 38 createOAuthAdminIfNotExist(callbackAsync)
38 } 39 }
39 ], callback) 40 ], callback)
40} 41}
@@ -80,7 +81,7 @@ function createOAuthClientIfNotExist (callback) {
80 }) 81 })
81} 82}
82 83
83function createOAuthUserIfNotExist (callback) { 84function createOAuthAdminIfNotExist (callback) {
84 checker.usersExist(function (err, exist) { 85 checker.usersExist(function (err, exist) {
85 if (err) return callback(err) 86 if (err) return callback(err)
86 87
@@ -90,6 +91,7 @@ function createOAuthUserIfNotExist (callback) {
90 logger.info('Creating the administrator.') 91 logger.info('Creating the administrator.')
91 92
92 const username = 'root' 93 const username = 'root'
94 const role = constants.USER_ROLES.ADMIN
93 let password = '' 95 let password = ''
94 96
95 // Do not generate a random password for tests 97 // Do not generate a random password for tests
@@ -105,7 +107,8 @@ function createOAuthUserIfNotExist (callback) {
105 107
106 const user = new User({ 108 const user = new User({
107 username: username, 109 username: username,
108 password: password 110 password: password,
111 role: role
109 }) 112 })
110 113
111 user.save(function (err, createdUser) { 114 user.save(function (err, createdUser) {