Allow create user with JSON via env INITIAL_USER

pull/6283/head
Rodrigo Nascimento 8 years ago
parent 24e2b81f58
commit f3c68d6b82
  1. 16
      server/startup/initialData.js

@ -106,6 +106,22 @@ Meteor.startup(function() {
}
}
if (typeof process.env.INITIAL_USER === 'string' && process.env.INITIAL_USER.length > 0) {
try {
const initialUser = JSON.parse(process.env.INITIAL_USER);
if (!initialUser._id) {
console.log('No _id provided; Ignoring environment variable INITIAL_USER'.red);
} else if (!RocketChat.models.Users.findOneById(initialUser._id)) {
console.log('Inserting initial user:'.green);
console.log(JSON.stringify(initialUser, null, 2).green);
RocketChat.models.Users.create(initialUser);
}
} catch (e) {
console.log('Error processing environment variable INITIAL_USER'.red, e);
}
}
if (_.isEmpty(RocketChat.authz.getUsersInRole('admin').fetch())) {
const oldestUser = RocketChat.models.Users.findOne({
_id: {

Loading…
Cancel
Save