Skip to content

Commit

Permalink
Merge pull request #952 from reactioncommerce/brent-rough-fix-for-def…
Browse files Browse the repository at this point in the history
…ault-admin

Workaround for error that occurs on startup in Docker containers because `shopId` is not ready
  • Loading branch information
brent-hoover committed Apr 5, 2016
2 parents 4353863 + 9bc111c commit f3e5711
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/reaction-core/server/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ ReactionImport.identify = function (document) {
/**
* @summary Commit the buffer for a given collection to the database.
* @param {Mongo.Collection} collection The target collection to be flushed to disk
* @param {function} callback Function to execute after flush succeeded
* @returns {undefined}
*/
ReactionImport.flush = function (collection) {
check(collection, Match.Optional(Mongo.Collection));

if (!collection) {
for (let name of Object.keys(this._buffers)) {
this.flush(ReactionCore.Collections[name]);
Expand Down
9 changes: 8 additions & 1 deletion packages/reaction-core/server/registry/defaultAdmin.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,21 @@
* @returns {String} return userId
*/
ReactionRegistry.createDefaultAdminUser = function () {
ReactionCore.Log.info("Starting createDefaultAdminUser");
let options = {};
const domain = ReactionRegistry.getRegistryDomain();
const defaultAdminRoles = ["owner", "admin", "guest", "account/profile"];
const shopId = ReactionCore.getShopId();
let accountId;

while (!ReactionCore.getShopId()) {
ReactionCore.Log.info("No shopId, waiting one second...");
Meteor._sleepForMs(1000);
}
const shopId = ReactionCore.getShopId();

// if an admin user has already been created, we'll exit
if (Roles.getUsersInRole(defaultAdminRoles, shopId).count() !== 0) {
ReactionCore.Log.info("Not creating default admin user, already exists");
return ""; // this default admin has already been created for this shop.
}

Expand Down

0 comments on commit f3e5711

Please sign in to comment.