@dhyasama/totem-models 3.2.1 → 3.3.1

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 CHANGED
@@ -14,33 +14,9 @@ module.exports = function(mongoose, config) {
14
14
  var Account = new Schema({
15
15
 
16
16
  username: { type: String, required: true, unique: true },
17
- password: { type: String, default: '' },
18
17
  email: { type: String, required: true, unique: true },
19
- reset: {
20
- token: { type: String },
21
- expiresOn: { type: Date }
22
- },
23
- setup: {
24
- token: { type: String },
25
- expiresOn: { type: Date },
26
- complete: { type: Boolean},
27
- terms: {
28
- raw: { type: String },
29
- hash: { type: String }
30
- }
31
- },
32
- twoFactorAuth: {
33
- enabled: { type: Boolean },
34
- phone: { type: String },
35
- country: {
36
- callingCode: { type: String },
37
- abbreviation: { type: String }
38
- },
39
- verified: { type: Boolean }
40
- },
41
18
  admin: { type: Boolean },
42
19
  active: { type: Boolean },
43
- subscriber: { type: Boolean },
44
20
  role: { type: String, enum: ['admin', 'lp-full', 'lp-names', 'welcome', 'none'] },
45
21
 
46
22
  // Enable this and iLevel links will show on portfolio pages
@@ -85,12 +61,30 @@ module.exports = function(mongoose, config) {
85
61
  calendar: {
86
62
  active: { type: Boolean, default: false }, // only pull if this is active
87
63
  forcePullAll: { type: Boolean, default: false } // override newest event date as min and go back all the way
64
+ },
65
+
66
+ inbound: {
67
+ active: { type: Boolean, default: false }
88
68
  }
89
69
 
90
70
  });
91
71
 
92
- Account.methods.phone = function() {
93
- return this.twoFactorAuth.country.callingCode + this.twoFactorAuth.phone;
72
+ Account.statics.findByEmail = function(email, cb) {
73
+ this
74
+ .findOne({ 'email': email})
75
+ .populate('person')
76
+ .exec(function (err, account) {
77
+ cb(err, account);
78
+ });
79
+ };
80
+
81
+ Account.statics.findByUsername = function(username, cb) {
82
+ this
83
+ .findOne({ 'username': new RegExp(username, 'i') })
84
+ .populate('person')
85
+ .exec(function (err, account) {
86
+ cb(err, account);
87
+ });
94
88
  };
95
89
 
96
90
  Account.statics.getById = function (id, cb) {
@@ -127,91 +121,6 @@ module.exports = function(mongoose, config) {
127
121
  .exec(cb);
128
122
  };
129
123
 
130
- Account.statics.upsert = function(account, cb) {
131
- account.save(cb);
132
- };
133
-
134
- Account.statics.findByUsername = function(username, cb) {
135
- this
136
- .findOne({ 'username': new RegExp(username, 'i') })
137
- .populate('person')
138
- .exec(function (err, account) {
139
- cb(err, account);
140
- });
141
- };
142
-
143
- Account.statics.findByEmail = function(email, cb) {
144
- this
145
- .findOne({ 'email': email})
146
- .populate('person')
147
- .exec(function (err, account) {
148
- cb(err, account);
149
- });
150
- };
151
-
152
- Account.statics.findByffEmail = function(email, cb) {
153
- email = email.toLowerCase();
154
-
155
- if (email.indexOf('@ffvc.com') > -1) {
156
- this
157
- .findOne({ 'email': email})
158
- .populate('person')
159
- .exec(function (err, account) {
160
- cb(err, account);
161
- });
162
- } else {
163
- //passing in null err so passport hits failureRedirect: '/login'
164
- cb(null, null);
165
- }
166
- };
167
-
168
- Account.statics.findByResetToken = function(token, cb) {
169
- this
170
- .findOne({ 'reset.token': token})
171
- .populate('person')
172
- .exec(function (err, account) {
173
- cb(err, account);
174
- });
175
- };
176
-
177
- Account.statics.findBySetupToken = function(token, cb) {
178
- this
179
- .findOne({ 'setup.token': token})
180
- .populate('person')
181
- .exec(function (err, account) {
182
- cb(err, account);
183
- });
184
- };
185
-
186
- Account.statics.findByCredentials = function (username, cleartextPassword, cb) {
187
-
188
- this
189
- .findOne({ 'username': new RegExp(username, 'i') })
190
- .populate('person')
191
- .exec(function (err, account) {
192
-
193
- if (err) {
194
- return cb(err, null);
195
- }
196
- else if (account != null) {
197
-
198
- // found user, now check password
199
-
200
- bcrypt.compare(cleartextPassword, account.password, function(err, res) {
201
- if (err) { return cb(err, null); } // error
202
- else if (res) { return cb(null, account); } // correct password
203
- else { return cb(null, null); } // wrong password
204
- });
205
-
206
- }
207
- else {
208
- return cb(null, null); // user not found
209
- }
210
-
211
- });
212
-
213
- };
214
-
215
124
  Account.statics.listGoogleAccounts = function(cb) {
216
125
 
217
126
  this
@@ -252,6 +161,10 @@ module.exports = function(mongoose, config) {
252
161
 
253
162
  };
254
163
 
164
+ Account.statics.upsert = function(account, cb) {
165
+ account.save(cb);
166
+ };
167
+
255
168
  Account.post('remove', function(doc) {
256
169
  // CalendarEvent.account
257
170
  // Person.account
@@ -175,6 +175,14 @@ module.exports = function(mongoose, config) {
175
175
 
176
176
  eshares: {
177
177
  firmid: { type: String, unique: true, partialFilterExpression : { type :"string" }, trim: true }
178
+ },
179
+
180
+ calendar: {
181
+ active: { type: Boolean, default: false }
182
+ },
183
+
184
+ inbound: {
185
+ active: { type: Boolean, default: false }
178
186
  }
179
187
 
180
188
  },
@@ -722,7 +730,7 @@ module.exports = function(mongoose, config) {
722
730
  };
723
731
 
724
732
  Organization.statics.findBySlugs = function findBySlugs(slugs, cb) {
725
- this.find({ 'slug': { $in : slugs }, 'deleted': {$ne: true} }).exec(cb);
733
+ this.find({ 'slug': { $in : slugs } }).exec(cb);
726
734
  };
727
735
 
728
736
  Organization.statics.findDupes = function findDupes(org, options, cb) {
package/lib/Person.js CHANGED
@@ -806,7 +806,7 @@ module.exports = function(mongoose, config) {
806
806
 
807
807
  Person.statics.findBySlugs = function (slugs, cb) {
808
808
  this
809
- .find({ 'slug': { $in : slugs }, 'deleted': {$ne: true} })
809
+ .find({ 'slug': { $in : slugs } })
810
810
  .exec(cb);
811
811
  };
812
812
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "3.2.1",
3
+ "version": "3.3.1",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",
@@ -15,8 +15,8 @@
15
15
  "@dhyasama/ffvc-crypto": "^1.0.0",
16
16
  "@dhyasama/ffvc-geoip": "^1.0.0",
17
17
  "@dhyasama/ffvc-s3": "^1.0.0",
18
- "@dhyasama/ffvc-utilities": "^2.2.0",
19
- "async": "^2.6.0",
18
+ "@dhyasama/ffvc-utilities": "^2.3.1",
19
+ "async": "^2.6.1",
20
20
  "awesome-phonenumber": "^1.0.14",
21
21
  "bcrypt": "^0.8.0",
22
22
  "bluebird": "^3.5.0",
package/test/Account.js CHANGED
@@ -45,10 +45,7 @@ describe('Account', function() {
45
45
  var account = new Account();
46
46
 
47
47
  account.username = 'testy';
48
- account.email = 'sebastian+soler@gmail.com'
49
- account.reset.token = '123456789';
50
- account.setup.token = '987654321';
51
- account.password = hash;
48
+ account.email = 'test@totemvc.com';
52
49
  account.person = newPerson;
53
50
  account.active = true;
54
51
 
@@ -88,37 +85,7 @@ describe('Account', function() {
88
85
 
89
86
  it('finds by email', function(done) {
90
87
 
91
- Account.findByEmail('sebastian+soler@gmail.com', function(err, account) {
92
- should.not.exist(err);
93
- should.exist(account);
94
- done();
95
- });
96
-
97
- });
98
-
99
- it('finds by reset token', function(done) {
100
-
101
- Account.findByResetToken('123456789', function(err, account) {
102
- should.not.exist(err);
103
- should.exist(account);
104
- done();
105
- });
106
-
107
- });
108
-
109
- it('finds by setup token', function(done) {
110
-
111
- Account.findBySetupToken('987654321', function(err, account) {
112
- should.not.exist(err);
113
- should.exist(account);
114
- done();
115
- });
116
-
117
- });
118
-
119
- it('finds by username and password', function(done) {
120
-
121
- Account.findByCredentials('testy', 'testy', function(err, account) {
88
+ Account.findByEmail('test@totemvc.com', function(err, account) {
122
89
  should.not.exist(err);
123
90
  should.exist(account);
124
91
  done();
package/test/Person.js CHANGED
@@ -537,9 +537,6 @@ describe('Person', function() {
537
537
 
538
538
  account.username = 'testy';
539
539
  account.email = 'test@ffvc.com';
540
- account.reset.token = '123456789';
541
- account.setup.token = '987654321';
542
- account.password = 'piratebooty';
543
540
  account.person = person;
544
541
 
545
542
  Account.upsert(account, function(err, updatedAccount) {
package/.npmignore DELETED
@@ -1,14 +0,0 @@
1
- lib-cov
2
- *.seed
3
- *.log
4
- *.csv
5
- *.dat
6
- *.out
7
- *.pid
8
- *.gz
9
-
10
- npm-debug.log
11
- node_modules
12
-
13
- .DS_Store
14
- .idea