Tighten password reset

This commit is contained in:
Loay 2016-07-26 13:19:41 -04:00
parent 46435bde0f
commit 76a390d03e
1 changed files with 29 additions and 1 deletions

View File

@ -1644,7 +1644,6 @@ describe('User', function() {
if (err) return done(err);
assert.equal(user.email, email);
done();
});
});
@ -1684,6 +1683,35 @@ describe('User', function() {
});
});
describe('password reset without requiring email verification', function() {
var email = 'foo1@bar.com';
it('disallows temp accessToken creation if email verification is required and done', function(done) {
var calledBack = false;
User.resetPassword({
email: 'foo1@bar.com',
}, function() {
calledBack = true;
});
User.once('resetPasswordRequest', function(info) {
assert(info.email);
assert(!info.accessToken);
assert(!info.accessToken.id);
assert.equal(info.accessToken.ttl / 60, 15);
assert(calledBack);
console.log(info);
info.accessToken.user(function(err, user) {
if (err) return done(err);
assert.equal(user.email, email);
console.log(user.emailVerified);
done();
});
});
});
});
describe('ctor', function() {
it('exports default Email model', function() {
expect(User.email, 'User.email').to.be.a('function');