Trim username and e-mail in login/registration form (#2888)

* Trim username and e-mail in login/registration form

* Add trim to the sendConfirmationEmail and sendForgotPasswordEmail
pull/3005/head
Marcelo Schmidt 10 years ago committed by Gabriel Engel
parent b8c6e20885
commit 4de88df6b7
  1. 8
      packages/rocketchat-ui-login/login/form.coffee
  2. 4
      server/methods/registerUser.coffee
  3. 4
      server/methods/sendConfirmationEmail.coffee
  4. 4
      server/methods/sendForgotPasswordEmail.coffee

@ -80,14 +80,14 @@ Template.loginForm.events
formData = instance.validate()
if formData
if instance.state.get() is 'email-verification'
Meteor.call 'sendConfirmationEmail', formData.email, (err, result) ->
Meteor.call 'sendConfirmationEmail', s.trim(formData.email), (err, result) ->
RocketChat.Button.reset(button)
toastr.success t('We_have_sent_registration_email')
instance.state.set 'login'
return
if instance.state.get() is 'forgot-password'
Meteor.call 'sendForgotPasswordEmail', formData.email, (err, result) ->
Meteor.call 'sendForgotPasswordEmail', s.trim(formData.email), (err, result) ->
RocketChat.Button.reset(button)
toastr.success t('We_have_sent_password_email')
instance.state.set 'login'
@ -105,7 +105,7 @@ Template.loginForm.events
toastr.error error.reason
return
Meteor.loginWithPassword formData.email, formData.pass, (error) ->
Meteor.loginWithPassword s.trim(formData.email), formData.pass, (error) ->
if error?.error is 'no-valid-email'
toastr.success t('We_have_sent_registration_email')
instance.state.set 'login'
@ -117,7 +117,7 @@ Template.loginForm.events
if RocketChat.settings.get('LDAP_Enable')
loginMethod = 'loginWithLDAP'
Meteor[loginMethod] formData.emailOrUsername.trim(), formData.pass, (error) ->
Meteor[loginMethod] s.trim(formData.emailOrUsername), formData.pass, (error) ->
RocketChat.Button.reset(button)
if error?
if error.error is 'no-valid-email'

@ -9,12 +9,12 @@ Meteor.methods
RocketChat.validateEmailDomain(formData.email);
userData =
email: formData.email
email: s.trim(formData.email)
password: formData.pass
userId = Accounts.createUser userData
RocketChat.models.Users.setName userId, formData.name
RocketChat.models.Users.setName userId, s.trim(formData.name)
if userData.email
Accounts.sendVerificationEmail(userId, userData.email);

@ -1,8 +1,8 @@
Meteor.methods
sendConfirmationEmail: (email) ->
user = RocketChat.models.Users.findOneByEmailAddress email
user = RocketChat.models.Users.findOneByEmailAddress s.trim(email)
if user?
Accounts.sendVerificationEmail(user._id, email)
Accounts.sendVerificationEmail(user._id, s.trim(email))
return true
return false

@ -1,8 +1,8 @@
Meteor.methods
sendForgotPasswordEmail: (email) ->
user = RocketChat.models.Users.findOneByEmailAddress email
user = RocketChat.models.Users.findOneByEmailAddress s.trim(email)
if user?
Accounts.sendResetPasswordEmail(user._id, email)
Accounts.sendResetPasswordEmail(user._id, s.trim(email))
return true
return false

Loading…
Cancel
Save