Skip to content

Commit

Permalink
Merge pull request strongloop#2440 from strongloop/issue414_token2
Browse files Browse the repository at this point in the history
Fix verificationToken bug
  • Loading branch information
loay authored Jun 17, 2016
2 parents 03e85b8 + ec51e83 commit 45e523d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion common/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,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) {
Expand Down
15 changes: 15 additions & 0 deletions test/user.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1418,6 +1418,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)
Expand Down

0 comments on commit 45e523d

Please sign in to comment.