Merge pull request #2440 from strongloop/issue414_token2

Fix verificationToken bug
This commit is contained in:
Loay 2016-06-17 11:12:16 -04:00 committed by GitHub
commit 45e523d66c
2 changed files with 16 additions and 1 deletions

View File

@ -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) {

View File

@ -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)