Skip to content

Commit

Permalink
Bug fix to prevent unconverted modules from incorrectly installing
Browse files Browse the repository at this point in the history
  • Loading branch information
brianhyder committed Mar 27, 2015
1 parent 07d32ed commit f081c07
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion include/service/entities/plugin_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -1878,7 +1878,7 @@ module.exports = function PluginServiceModule(pb) {
* @return {Boolean} TRUE if the path is valid, FALSE if not
*/
PluginService.validateMainModulePath = function(mmPath, pluginDirName) {
return PluginService.loadMainModule(pluginDirName, mmPath) !== null;
return !util.isNullOrUndefined(PluginService.loadMainModule(pluginDirName, mmPath));
};

/**
Expand Down
2 changes: 1 addition & 1 deletion include/service/jobs/plugins/plugin_install_job.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ module.exports = function PluginInstallJobModule(pb) {
function(callback) {

var mainModule = pb.PluginService.loadMainModule(pluginUid, details.main_module.path);
if (mainModule !== null && typeof mainModule.onInstall === 'function') {
if (!util.isNullOrUndefined(mainModule) && util.isFunction(mainModule.onInstall)) {
self.log("Executing %s 'onInstall' function", details.uid);
mainModule.onInstall(callback);
}
Expand Down
8 changes: 7 additions & 1 deletion include/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,13 @@ Util.getDirectories = function(dirPath, cb) {

var fullPath = path.join(dirPath, files[index]);
fs.stat(fullPath, function(err, stat) {
if (stat.isDirectory()) {
if (util.isError(err)) {
return cb(err);
}
if (Util.isNullOrUndefined(stat)) {
console.log('WARN: Util: unstatable file encountered: %s', fullPath);
}
else if (stat.isDirectory()) {
dirs.push(fullPath);
}
callback(err);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ module.exports = function(pb) {
passwordReset = pb.DocumentCreator.create('password_reset', {user_id: user[pb.DAO.getIdField()].toString()});
}

passwordReset.verification_code = util.uniqueId().toString();
passwordReset.verification_code = util.uniqueId();

dao.save(passwordReset, function(err, result) {
if(util.isError(err)) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/pencilblue/controllers/actions/forgot_password.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ module.exports = function ForgotPasswordControllerModule(pb) {
if(!passwordReset) {
passwordReset = pb.DocumentCreator.create('password_reset', {user_id: userIdStr});
}
passwordReset.verification_code = util.uniqueId().toString();
passwordReset.verification_code = util.uniqueId();

//persist reset entry
dao.save(passwordReset, function(err, result) {
Expand Down

0 comments on commit f081c07

Please sign in to comment.