@dhyasama/totem-models 3.4.0 → 3.4.2
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/Account.js +6 -5
- package/lib/Organization.js +7 -2
- package/package.json +1 -1
- package/test/Account.js +10 -0
package/lib/Account.js
CHANGED
|
@@ -70,12 +70,13 @@ module.exports = function(mongoose, config) {
|
|
|
70
70
|
});
|
|
71
71
|
|
|
72
72
|
Account.statics.findByEmail = function(email, cb) {
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
|
|
74
|
+
var self = this;
|
|
75
|
+
|
|
76
|
+
self
|
|
77
|
+
.findOne({ 'email': (email || '').toLowerCase()})
|
|
75
78
|
.populate('person')
|
|
76
|
-
.exec(
|
|
77
|
-
cb(err, account);
|
|
78
|
-
});
|
|
79
|
+
.exec(cb);
|
|
79
80
|
};
|
|
80
81
|
|
|
81
82
|
Account.statics.findByUsername = function(username, cb) {
|
package/lib/Organization.js
CHANGED
|
@@ -1333,12 +1333,17 @@ module.exports = function(mongoose, config) {
|
|
|
1333
1333
|
var cleanWebsites = function cleanWebsites() {
|
|
1334
1334
|
|
|
1335
1335
|
// Format website
|
|
1336
|
-
if (self.website)
|
|
1336
|
+
if (self.website) {
|
|
1337
|
+
self.website = utils.getDomain(self.website);
|
|
1338
|
+
self.website = self.website.replace('http://', '').replace('https://', '');
|
|
1339
|
+
}
|
|
1337
1340
|
|
|
1338
1341
|
// Format website aliases
|
|
1339
1342
|
if (self.websiteAliases && self.websiteAliases.length >= 1) {
|
|
1340
1343
|
self.websiteAliases = _.map(self.websiteAliases, function(alias) {
|
|
1341
|
-
|
|
1344
|
+
var website = utils.getDomain(alias);
|
|
1345
|
+
website = website.replace('http://', '').replace('https://', '');
|
|
1346
|
+
return utils.getDomain(website);
|
|
1342
1347
|
});
|
|
1343
1348
|
}
|
|
1344
1349
|
|
package/package.json
CHANGED
package/test/Account.js
CHANGED
|
@@ -93,6 +93,16 @@ describe('Account', function() {
|
|
|
93
93
|
|
|
94
94
|
});
|
|
95
95
|
|
|
96
|
+
it('finds by uppercase email', function(done) {
|
|
97
|
+
|
|
98
|
+
Account.findByEmail('TEST@TOTEMVC.COM', function(err, account) {
|
|
99
|
+
should.not.exist(err);
|
|
100
|
+
should.exist(account);
|
|
101
|
+
done();
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
});
|
|
105
|
+
|
|
96
106
|
it('lists all active accounts', function(done) {
|
|
97
107
|
|
|
98
108
|
Account.listAllAccounts(function(err, result) {
|