From 9f2c35e253cef96cc6be60caae47f2c3cfd833a8 Mon Sep 17 00:00:00 2001 From: Adrian Lanning Date: Sun, 31 May 2015 00:25:04 -0400 Subject: [PATCH] Fix email verification token index The original index, "emails.validationTokens.token" is never used in any meteor packages. A search of "validationTokens" across all the packages in `meteor/packages` returns nothing. The correct index should be, "services.email.verificationTokens.token". This is used in the `verifyEmail` method to locate the correct user record. Without a matching index, this causes a full table scan each time `verifyEmail` is called. Fixes #4482. --- History.md | 4 ++++ packages/accounts-password/password_server.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/History.md b/History.md index c720e9045e..e48eaf8818 100644 --- a/History.md +++ b/History.md @@ -100,6 +100,10 @@ `AccountsServer` constructors, so that users can create multiple independent instances of the `Accounts` namespace. #4233 +* Create an index for `Meteor.users` on + `services.email.verificationTokens.token` (instead of + `emails.validationTokens.token`, which never was used for anything). #4482 + ### Minimongo * The `$push` query modifier now supports a `$position` argument. #4312 diff --git a/packages/accounts-password/password_server.js b/packages/accounts-password/password_server.js index 8b8f55b9b0..b47fe5019c 100644 --- a/packages/accounts-password/password_server.js +++ b/packages/accounts-password/password_server.js @@ -779,7 +779,7 @@ Accounts.createUser = function (options, callback) { /// /// PASSWORD-SPECIFIC INDEXES ON USERS /// -Meteor.users._ensureIndex('emails.validationTokens.token', +Meteor.users._ensureIndex('services.email.verificationTokens.token', {unique: 1, sparse: 1}); Meteor.users._ensureIndex('services.password.reset.token', {unique: 1, sparse: 1});