Fix verificationToken bug #2440

This commit is contained in:
Loay 2016-06-16 02:20:33 -04:00
parent 7e051a7549
commit 4480cd92ab
2 changed files with 16 additions and 1 deletions

View File

@ -474,7 +474,7 @@ module.exports = function(User) {
fn(err);
} else {
if (user && user.verificationToken === token) {
user.verificationToken = undefined;
user.verificationToken = null;
user.emailVerified = true;
user.save(function(err) {
if (err) {

View File

@ -1422,6 +1422,21 @@ describe('User', function() {
}, done);
});
it('sets verificationToken to null after confirmation', function(done) {
testConfirm(function(result, done) {
User.confirm(result.uid, result.token, false, function(err) {
if (err) return done(err);
// Verify by loading user data stored in the datasource
User.findById(result.uid, function(err, user) {
if (err) return done(err);
expect(user).to.have.property('verificationToken', null);
done();
});
});
}, done);
});
it('Should report 302 when redirect url is set', function(done) {
testConfirm(function(result, done) {
request(app)