Skip to content

Commit

Permalink
#1031 Added support for Node 6
Browse files Browse the repository at this point in the history
  • Loading branch information
brianhyder committed May 9, 2016
1 parent 699237d commit 13b919e
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 13 deletions.
6 changes: 6 additions & 0 deletions controllers/base_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,12 @@ module.exports = function BaseControllerModule(pb) {

//convert to string
var postParams = url.parse('?' + raw.toString(encoding), true).query;

//In Node v6 a breaking change was introduced into the "querystring" module to prevent reserved words from
// being passed in as query string parameters and overriding prototype functions.
// This fix allows for users to continue on with V6 until another viable option comes along
postParams.hawOwnProperty = Object.prototype.hasOwnProperty;

cb(null, postParams);
});
};
Expand Down
6 changes: 3 additions & 3 deletions controllers/form_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
var util = require('../include/util.js');

module.exports = function(pb) {

/**
* Provides the basic functionality for implementing a controller that
* needs access to a posted form.
Expand Down Expand Up @@ -77,7 +77,7 @@ module.exports = function(pb) {
* @param {Boolean} val
*/
FormController.prototype.setAutoSanitize = function(val) {
this.autoSanitize = val ? true : false;
this.autoSanitize = !!val;
};

/**
Expand All @@ -103,6 +103,6 @@ module.exports = function(pb) {
FormController.prototype.onPostParamsRetrieved = function(params, cb) {
cb({content: JSON.stringify(params), content_type:'application/json'});
};

return FormController;
};
4 changes: 2 additions & 2 deletions include/admin_navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,10 @@ module.exports = function AdminNavigationModule(pb) {
* @param {String} site
*/
function getAdditionsInScope(additions, site) {
if (additions.hasOwnProperty(site)) {
if (additions[site]) {
return util.clone(additions[site]);
}
else if (additions.hasOwnProperty(pb.SiteService.GLOBAL_SITE)) {
else if (additions[pb.SiteService.GLOBAL_SITE]) {
return util.clone(additions[pb.SiteService.GLOBAL_SITE]);
}
return util.clone(additions);
Expand Down
2 changes: 1 addition & 1 deletion include/dao/db_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ module.exports = function DBManagerModule(pb) {
* @return {Boolean} Whether the pool has been connected
*/
this.hasConnected = function(name){
return dbs.hasOwnProperty(name);
return typeof dbs[name] !== 'undefined';
};

/**
Expand Down
8 changes: 4 additions & 4 deletions include/model/create_document.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ module.exports = function DocumentCreatorModule(pb) {
return false;
}

if (post.hasOwnProperty('password')) {
post['password'] = pb.security.encrypt(post['password']);
if (post.password) {
post.password = pb.security.encrypt(post.password);
}

if(post['confirm_password']) {
delete post['confirm_password'];
if(post.confirm_password) {
delete post.confirm_password;
}
};

Expand Down
2 changes: 1 addition & 1 deletion include/security/authentication/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ module.exports = function AuthenticationModule(pb) {
}

var dao;
if (credentials.hasOwnProperty('site')) {
if (credentials.site) {
dao = new pb.SiteQueryService({site: credentials.site, onlyThisSite: false});
} else {
dao = new pb.DAO();
Expand Down
2 changes: 1 addition & 1 deletion include/service/memory_entity_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ module.exports = function MemoryEntityServiceModule(pb) {
MemoryEntityService.prototype._set = function(key, value, cb) {
var rawValue = null;
var internalKey = MemoryEntityService.getKey(key, this.site, this.objType);
if (STORAGE.hasOwnProperty(internalKey)) {
if (STORAGE[internalKey]) {
rawValue = STORAGE[internalKey];
if (this.valueField == null) {
rawValue = value;
Expand Down
2 changes: 1 addition & 1 deletion include/system/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ module.exports = function SettingsModule(pb) {

//validate key is not taken
var where = { key: new RegExp('^' + util.escapeRegExp(obj.key) + '$', 'i') };
context.service.dao.exists(TYPE, where, function(err, exists) {console.log(context);
context.service.dao.exists(TYPE, where, function(err, exists) {
if (exists && context.isCreate) {
errors.push(pb.BaseObjectService.validationFailure('key', 'key already exists'));
}
Expand Down

0 comments on commit 13b919e

Please sign in to comment.