From 7acbcfd848f835939600b69cc8facafc8af22643 Mon Sep 17 00:00:00 2001 From: Gabriel Engel Date: Wed, 31 Aug 2016 14:54:25 -0300 Subject: [PATCH 1/2] Fix E-Mail address in reset password form is case-sensitive (#4158) --- server/methods/sendForgotPasswordEmail.coffee | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/server/methods/sendForgotPasswordEmail.coffee b/server/methods/sendForgotPasswordEmail.coffee index 32adedb8fba9..cd64e3916b96 100644 --- a/server/methods/sendForgotPasswordEmail.coffee +++ b/server/methods/sendForgotPasswordEmail.coffee @@ -1,8 +1,15 @@ Meteor.methods sendForgotPasswordEmail: (email) -> - user = RocketChat.models.Users.findOneByEmailAddress s.trim(email.toLowerCase()) + + email = s.trim(email) + user = RocketChat.models.Users.findOneByEmailAddress(email) + regex = new RegExp("^" + s.escapeRegExp(email) + "$", 'i') + + email = _.find(_.pluck(user.emails || [], 'address'), (userEmail) -> + return regex.test(userEmail) if user? - Accounts.sendResetPasswordEmail(user._id, s.trim(email)) + Accounts.sendResetPasswordEmail(user._id, email) return true + return false From cae1d865b8c818e4e81107443f65ee459162ee4b Mon Sep 17 00:00:00 2001 From: Gabriel Engel Date: Wed, 31 Aug 2016 15:15:16 -0300 Subject: [PATCH 2/2] fix server/methods/sendForgotPasswordEmail.coffee:15:15: unmatched OUTDENT --- server/methods/sendForgotPasswordEmail.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/methods/sendForgotPasswordEmail.coffee b/server/methods/sendForgotPasswordEmail.coffee index cd64e3916b96..549ded5c54f2 100644 --- a/server/methods/sendForgotPasswordEmail.coffee +++ b/server/methods/sendForgotPasswordEmail.coffee @@ -5,7 +5,7 @@ Meteor.methods user = RocketChat.models.Users.findOneByEmailAddress(email) regex = new RegExp("^" + s.escapeRegExp(email) + "$", 'i') - email = _.find(_.pluck(user.emails || [], 'address'), (userEmail) -> + email = _.find _.pluck(user.emails || [], 'address'), (userEmail) -> return regex.test(userEmail) if user?