Merge pull request #956 from clarkorz/fix/user-settings-ttl

fix User.settings.ttl can't be overridden in sub model
This commit is contained in:
Ritchie Martori 2015-01-05 09:38:18 -08:00
commit 38bb8f9064
2 changed files with 11 additions and 1 deletions

View File

@ -464,7 +464,7 @@ module.exports = function(User) {
// max ttl // max ttl
this.settings.maxTTL = this.settings.maxTTL || DEFAULT_MAX_TTL; this.settings.maxTTL = this.settings.maxTTL || DEFAULT_MAX_TTL;
this.settings.ttl = DEFAULT_TTL; this.settings.ttl = this.settings.ttl || DEFAULT_TTL;
UserModel.setter.password = function(plain) { UserModel.setter.password = function(plain) {
var salt = bcrypt.genSaltSync(this.constructor.settings.saltWorkFactor || SALT_WORK_FACTOR); var salt = bcrypt.genSaltSync(this.constructor.settings.saltWorkFactor || SALT_WORK_FACTOR);

View File

@ -808,4 +808,14 @@ describe('User', function() {
expect(User.accessToken.modelName, 'modelName').to.eql('AccessToken'); expect(User.accessToken.modelName, 'modelName').to.eql('AccessToken');
}); });
}); });
describe('ttl', function() {
var User2;
beforeEach(function() {
User2 = loopback.User.extend('User2', {}, { ttl: 10 });
});
it('should override ttl setting in based User model', function() {
expect(User2.settings.ttl).to.equal(10);
});
});
}); });