Skip to content

Commit

Permalink
Merge pull request #4163 from RocketChat/fix-case-sensitive-password-…
Browse files Browse the repository at this point in the history
…reset

Fix E-Mail address in reset password form is case-sensitive (#4158)
  • Loading branch information
engelgabriel committed Aug 31, 2016
2 parents 435fcef + cae1d86 commit 3fc016a
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 3fc016a

Please sign in to comment.