Create the admin group only on owner creation
For new cloudrons this will first remove the previously added group and mailbox entry from the db migration scripts and readds it once we have a domain on owner creation
This commit is contained in:
17
src/user.js
17
src/user.js
@@ -32,6 +32,7 @@ var assert = require('assert'),
|
||||
debug = require('debug')('box:user'),
|
||||
DatabaseError = require('./databaseerror.js'),
|
||||
eventlog = require('./eventlog.js'),
|
||||
groupdb = require('./groupdb.js'),
|
||||
groups = require('./groups.js'),
|
||||
GroupError = groups.GroupError,
|
||||
hat = require('hat'),
|
||||
@@ -551,13 +552,19 @@ function createOwner(username, password, email, displayName, auditSource, callba
|
||||
if (error) return callback(new UserError(UserError.INTERNAL_ERROR, error));
|
||||
if (count !== 0) return callback(new UserError(UserError.ALREADY_EXISTS, 'Owner already exists'));
|
||||
|
||||
createUser(username, password, email, displayName, auditSource, { owner: true }, function (error, user) {
|
||||
if (error) return callback(error);
|
||||
// have to provide the group id explicitly so using db layer directly
|
||||
groupdb.add(constants.ADMIN_GROUP_ID, constants.ADMIN_GROUP_NAME, function (error) {
|
||||
// we proceed if it already exists so we can re-create the owner if need be
|
||||
if (error && error.reason !== DatabaseError.ALREADY_EXISTS) return callback(new UserError(UserError.INTERNAL_ERROR, error));
|
||||
|
||||
groups.addMember(constants.ADMIN_GROUP_ID, user.id, function (error) {
|
||||
if (error) return callback(new UserError(UserError.INTERNAL_ERROR, error));
|
||||
createUser(username, password, email, displayName, auditSource, { owner: true }, function (error, user) {
|
||||
if (error) return callback(error);
|
||||
|
||||
callback(null, user);
|
||||
groups.addMember(constants.ADMIN_GROUP_ID, user.id, function (error) {
|
||||
if (error) return callback(new UserError(UserError.INTERNAL_ERROR, error));
|
||||
|
||||
callback(null, user);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user