aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/installer.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-12-28 15:49:23 +0100
committerChocobozzz <florian.bigard@gmail.com>2016-12-28 15:49:23 +0100
commit67bf9b96bbcd92b069fe86d9223fe0f8b9c6e677 (patch)
treebae6a9b0c3133c9cc38a2972222b5991f0cf614e /server/initializers/installer.js
parent552cc9d646e78edae8b0fe61564d4e49db0b6206 (diff)
downloadPeerTube-67bf9b96bbcd92b069fe86d9223fe0f8b9c6e677.tar.gz
PeerTube-67bf9b96bbcd92b069fe86d9223fe0f8b9c6e677.tar.zst
PeerTube-67bf9b96bbcd92b069fe86d9223fe0f8b9c6e677.zip
Server: add database field validations
Diffstat (limited to 'server/initializers/installer.js')
-rw-r--r--server/initializers/installer.js10
1 files changed, 7 insertions, 3 deletions
diff --git a/server/initializers/installer.js b/server/initializers/installer.js
index d5382364e..fb63b81ac 100644
--- a/server/initializers/installer.js
+++ b/server/initializers/installer.js
@@ -96,6 +96,7 @@ function createOAuthAdminIfNotExist (callback) {
96 96
97 const username = 'root' 97 const username = 'root'
98 const role = constants.USER_ROLES.ADMIN 98 const role = constants.USER_ROLES.ADMIN
99 const createOptions = {}
99 let password = '' 100 let password = ''
100 101
101 // Do not generate a random password for tests 102 // Do not generate a random password for tests
@@ -105,17 +106,20 @@ function createOAuthAdminIfNotExist (callback) {
105 if (process.env.NODE_APP_INSTANCE) { 106 if (process.env.NODE_APP_INSTANCE) {
106 password += process.env.NODE_APP_INSTANCE 107 password += process.env.NODE_APP_INSTANCE
107 } 108 }
109
110 // Our password is weak so do not validate it
111 createOptions.validate = false
108 } else { 112 } else {
109 password = passwordGenerator(8, true) 113 password = passwordGenerator(8, true)
110 } 114 }
111 115
112 const user = db.User.build({ 116 const userData = {
113 username, 117 username,
114 password, 118 password,
115 role 119 role
116 }) 120 }
117 121
118 user.save().asCallback(function (err, createdUser) { 122 db.User.create(userData, createOptions).asCallback(function (err, createdUser) {
119 if (err) return callback(err) 123 if (err) return callback(err)
120 124
121 logger.info('Username: ' + username) 125 logger.info('Username: ' + username)