Skip to content

Commit

Permalink
Fix E-Mail address in reset password form is case-sensitive (#4158)
Browse files Browse the repository at this point in the history
  • Loading branch information
engelgabriel committed Aug 31, 2016
1 parent a18b6fc commit 7acbcfd
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions server/methods/sendForgotPasswordEmail.coffee
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 7acbcfd

Please sign in to comment.