diff --git a/packages/rocketchat-ui-login/login/form.coffee b/packages/rocketchat-ui-login/login/form.coffee index c37727bd19c2..a705dd4fc9cd 100644 --- a/packages/rocketchat-ui-login/login/form.coffee +++ b/packages/rocketchat-ui-login/login/form.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' diff --git a/server/methods/registerUser.coffee b/server/methods/registerUser.coffee index 5f6c02db7358..b9905265038f 100644 --- a/server/methods/registerUser.coffee +++ b/server/methods/registerUser.coffee @@ -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); diff --git a/server/methods/sendConfirmationEmail.coffee b/server/methods/sendConfirmationEmail.coffee index 40c1819d8d1f..cc73b867dfe2 100644 --- a/server/methods/sendConfirmationEmail.coffee +++ b/server/methods/sendConfirmationEmail.coffee @@ -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 diff --git a/server/methods/sendForgotPasswordEmail.coffee b/server/methods/sendForgotPasswordEmail.coffee index 34dbf32eafe1..699bbc5924a1 100644 --- a/server/methods/sendForgotPasswordEmail.coffee +++ b/server/methods/sendForgotPasswordEmail.coffee @@ -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