@dhyasama/totem-models 8.0.6 → 8.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Organization.js +12 -5
- package/package.json +1 -1
package/lib/Organization.js
CHANGED
|
@@ -1058,8 +1058,13 @@ module.exports = function(mongoose, config) {
|
|
|
1058
1058
|
if (!cb) { throw new Error('cb is required'); }
|
|
1059
1059
|
if (!domains) { return cb(new Error('domains is required'), null); }
|
|
1060
1060
|
if (!options) { return cb(new Error('options is required'), null); }
|
|
1061
|
-
|
|
1062
|
-
|
|
1061
|
+
|
|
1062
|
+
options = helpers.getDefaultOptions(options);
|
|
1063
|
+
|
|
1064
|
+
if (!options.isWorkerProcess) {
|
|
1065
|
+
if (!options.CUSTOMER_ID) { return cb(new Error('options.CUSTOMER_ID is required'), null); }
|
|
1066
|
+
if (!mongoose.Types.ObjectId.isValid(options.CUSTOMER_ID)) { return cb(new Error('options.CUSTOMER_ID is not a valid ObjectId'), null); }
|
|
1067
|
+
}
|
|
1063
1068
|
|
|
1064
1069
|
// we haven't been able to avoid some domains having a protocol prefix in the database
|
|
1065
1070
|
// until we can, use protocol as part of searching by domain
|
|
@@ -1091,9 +1096,11 @@ module.exports = function(mongoose, config) {
|
|
|
1091
1096
|
if (err) { return cb(err, null); }
|
|
1092
1097
|
else if (!orgs) { return cb(null, []); }
|
|
1093
1098
|
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1099
|
+
if (!options.isWorkerProcess) {
|
|
1100
|
+
orgs = _.map(orgs, function(org) {
|
|
1101
|
+
return helpers.cleanOrg(org, options.CUSTOMER_ID);
|
|
1102
|
+
});
|
|
1103
|
+
}
|
|
1097
1104
|
|
|
1098
1105
|
return cb(null, orgs);
|
|
1099
1106
|
|