Skip to content

Commit

Permalink
Fix issue with _expirePasswordResetTokens for meteor#7534
Browse files Browse the repository at this point in the history
Also added a test to actually execute this code
  • Loading branch information
tmeasday committed Aug 15, 2016
1 parent a78dde0 commit f9f94e2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/accounts-base/accounts_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,7 @@ Ap._expirePasswordResetTokens = function (oldestValidDate, userId) {
{ "services.password.reset.when": { $lt: +oldestValidDate } }
]
}), {
$pull: {
$unset: {
"services.password.reset": {
$or: [
{ when: { $lt: oldestValidDate } },
Expand Down
14 changes: 14 additions & 0 deletions packages/accounts-password/password_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -1468,6 +1468,20 @@ if (Meteor.isServer) (function () {
}, /Incorrect password/);
});

Tinytest.add(
'passwords - reset tokens get cleaned up',
function (test) {
var email = test.id + '[email protected]';
var userId = Accounts.createUser({email: email, password: 'password'});
Accounts.sendResetPasswordEmail(userId, email);
test.isTrue(!!Meteor.users.findOne(userId).services.password.reset);

Accounts._expirePasswordResetTokens(new Date(), userId);

test.isUndefined(Meteor.users.findOne(userId).services.password.reset);
}
)

// We should be able to change the username
Tinytest.add("passwords - change username", function (test) {
var username = Random.id();
Expand Down

0 comments on commit f9f94e2

Please sign in to comment.