Fix issue with _expirePasswordResetTokens for #7534

Also added a test to actually execute this code
This commit is contained in:
Tom Coleman
2016-08-15 12:01:56 +10:00
parent a78dde0225
commit f9f94e21d1
2 changed files with 15 additions and 1 deletions

View File

@@ -1140,7 +1140,7 @@ Ap._expirePasswordResetTokens = function (oldestValidDate, userId) {
{ "services.password.reset.when": { $lt: +oldestValidDate } }
]
}), {
$pull: {
$unset: {
"services.password.reset": {
$or: [
{ when: { $lt: oldestValidDate } },

View File

@@ -1468,6 +1468,20 @@ if (Meteor.isServer) (function () {
}, /Incorrect password/);
});
Tinytest.add(
'passwords - reset tokens get cleaned up',
function (test) {
var email = test.id + '-intercept@example.com';
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();