mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Fix issue with _expirePasswordResetTokens for #7534
Also added a test to actually execute this code
This commit is contained in:
@@ -1140,7 +1140,7 @@ Ap._expirePasswordResetTokens = function (oldestValidDate, userId) {
|
||||
{ "services.password.reset.when": { $lt: +oldestValidDate } }
|
||||
]
|
||||
}), {
|
||||
$pull: {
|
||||
$unset: {
|
||||
"services.password.reset": {
|
||||
$or: [
|
||||
{ when: { $lt: oldestValidDate } },
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user