Skip to content

Commit

Permalink
Merge pull request #3123 from strongloop/backport/fix-user-reset-pass…
Browse files Browse the repository at this point in the history
…word

Fix User.resetPassword to call createAccessToken()
  • Loading branch information
bajtos authored Jan 20, 2017
2 parents d35e1a1 + b8f9b85 commit f355f66
Show file tree
Hide file tree
Showing 2 changed files with 14 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 @@ -605,7 +605,7 @@ module.exports = function(User) {
return cb(err);
}

user.accessTokens.create({ ttl: ttl }, function(err, accessToken) {
user.createAccessToken(ttl, function(err, accessToken) {
if (err) {
return cb(err);
}
Expand Down
13 changes: 13 additions & 0 deletions test/user.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1884,6 +1884,19 @@ describe('User', function() {
});
});

it('calls createAccessToken() to create the token', function(done) {
User.prototype.createAccessToken = function(ttl, cb) {
cb(null, new AccessToken({id: 'custom-token'}));
};

User.resetPassword({email: options.email}, function() {});

User.once('resetPasswordRequest', function(info) {
expect(info.accessToken.id).to.equal('custom-token');
done();
});
});

it('Password reset over REST rejected without email address', function(done) {
request(app)
.post('/test-users/reset')
Expand Down

0 comments on commit f355f66

Please sign in to comment.