Skip to content

Commit

Permalink
Trim username and e-mail in login/registration form (#2888)
Browse files Browse the repository at this point in the history
* Trim username and e-mail in login/registration form

* Add trim to the sendConfirmationEmail and sendForgotPasswordEmail
  • Loading branch information
marceloschmidt authored and engelgabriel committed Apr 14, 2016
1 parent b8c6e20 commit 4de88df
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions packages/rocketchat-ui-login/login/form.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand All @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions server/methods/registerUser.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions server/methods/sendConfirmationEmail.coffee
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions server/methods/sendForgotPasswordEmail.coffee
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 4de88df

Please sign in to comment.