Skip to content

Commit

Permalink
Cleanup and a couple of fixes for plugin installation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
brianhyder committed Dec 20, 2016
1 parent c3b3f6d commit 2cc5c9e
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 33 deletions.
3 changes: 3 additions & 0 deletions include/http/middleware/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,9 @@ module.exports = function(pb) {

//check permissions
result = RequestHandler.checkPermissions(ctx);
if (!result.success && pb.log.isDebug()) {
pb.log.debug('AuthCheck: %s', result.message);
}
next(result.success ? null : ErrorUtils.forbidden());
}

Expand Down
4 changes: 2 additions & 2 deletions include/http/request_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -1598,9 +1598,9 @@ module.exports = function RequestHandlerModule(pb) {

var result = {success: true};
var reqPerms = context.themeRoute.permissions;
var auth = context.session.authentication;
var auth = context.session.authentication;console.log('PermCheck: ', auth);
if (auth && auth.user &&
auth.access_level !== pb.SecurityService.ACCESS_ADMINISTRATOR &&
auth.admin_level !== pb.SecurityService.ACCESS_ADMINISTRATOR &&
auth.user.permissions &&
util.isArray(reqPerms)) {

Expand Down
6 changes: 5 additions & 1 deletion include/service/entities/plugin_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,11 @@ module.exports = function PluginServiceModule(pb) {
mainModule = require(paths[i])(pb);
break;
}
catch(e) {}
catch(e) {
if (pb.log.isDebug()) {
pb.log.warn('PluginService: Failed to load main module at %s: %s', paths[i], e.stack);
}
}
}
return mainModule;
};
Expand Down
11 changes: 6 additions & 5 deletions include/service/jobs/cluster_job_runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,6 @@ module.exports = function ClusterJobRunnerModule(pb) {
* for more details.
*/
ClusterJobRunner.prototype.processResults = function(err, results, cb) {
if (util.isError(err)) {
cb(err, results);
return;
}

//create function to handle cleanup and cb
var self = this;
var finishUp = function(err, result) {
Expand All @@ -121,6 +116,12 @@ module.exports = function ClusterJobRunnerModule(pb) {
cb(err, result);
};

//handle any error
if (util.isError(err)) {
return finishUp(err, results);
}

// decide how to process the result
if (this.isInitiator) {
this.processClusterResults(err, results, finishUp);
}
Expand Down
17 changes: 7 additions & 10 deletions include/service/jobs/plugins/plugin_install_job.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,9 @@ module.exports = function PluginInstallJobModule(pb) {
* @extends PluginJobRunner
*/
function PluginInstallJob(options){
if(options){
this.site = options.site || pb.SiteService.GLOBAL_SITE;
} else {
this.site = pb.SiteService.GLOBAL_SITE;
}
options = options || {};

this.site = options.site || pb.SiteService.GLOBAL_SITE;

PluginInstallJob.super_.call(this);

Expand Down Expand Up @@ -193,6 +191,9 @@ module.exports = function PluginInstallJobModule(pb) {
function(callback) {

var mainModule = pb.PluginService.loadMainModule(pluginUid, details.main_module.path);
if (!mainModule) {
return callback(new Error('Failed to load main module ' + pluginUid + ' at ' + details.main_module.path));
}
var hasBasicOnInstall = util.isFunction(mainModule.onInstall);
var hasContextOnInstall = util.isFunction(mainModule.onInstallWithContext);
if (!util.isNullOrUndefined(mainModule) && (hasBasicOnInstall || hasContextOnInstall)) {
Expand All @@ -211,11 +212,7 @@ module.exports = function PluginInstallJobModule(pb) {
}
];
async.series(tasks, function(err, results) {
if(util.isError(err)) {
cb(err);
return;
}
cb(null, true);
cb(err, !err);
});
};

Expand Down
3 changes: 1 addition & 2 deletions include/service/jobs/plugins/plugin_job_runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ module.exports = function PluginJobRunnerModule(pb) {
PluginJobRunner.prototype.processClusterResults = function(err, results, cb) {
if (util.isError(err)) {
this.log(err.stack);
cb(err, results);
return;
return cb(err, results);
}

var firstErr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,15 @@
$scope.jobAction = function(actionType, identifier, data, cb) {
$http.post("/api/jobs/" + actionType + "/" + encodeURIComponent(identifier), data)
.success(function(result) {
if (result.data.status === 'ERRORED') {
var error = {
message: result.data.error
};
return $scope.onActionFailure(error);
}
cb(result);
})
.error(function(error, status) {
.error(function(error) {
$scope.onActionFailure(error);
});
};
Expand Down Expand Up @@ -111,25 +117,21 @@
isInstalled = true;
}
});
if (isInstalled === true) {
return true;
} else {
return false;
}
}
return isInstalled === true;
};

$scope.onActionSuccess = function() {
$scope.actionIsComplete = true;
$scope.refreshPage();
}
};

$scope.onActionFailure = function(error) {
$scope.actionIsComplete = true;
$scope.actionError = error.message;
}
};

$scope.refreshPage = function() {
$window.location.reload();
}
};
});
</script>
6 changes: 3 additions & 3 deletions sample.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

module.exports = {
"siteName": "My PencilBlue Site",
"siteRoot": "http://127.0.0.1:8080",
"siteRoot": "http://localhost:8080",
"sitePort": 8080,
"logging": {
"level": "info"
Expand Down Expand Up @@ -45,7 +45,7 @@ module.exports = {
}
},
"registry": {
"type": "mongo"
"type": "redis"
},
"session": {
"storage": "mongo"
Expand All @@ -56,7 +56,7 @@ module.exports = {
},
"cluster": {
"workers": 1,
"self_managed": true
"self_managed": false
},
multisite: {
enabled: false,
Expand Down

0 comments on commit 2cc5c9e

Please sign in to comment.