Skip to content
Snippets Groups Projects
Unverified Commit af7e757d authored by Marcelo Schmidt's avatar Marcelo Schmidt
Browse files

Catch errors sending mail

parent 3a56e10e
No related branches found
No related tags found
No related merge requests found
......@@ -27,8 +27,10 @@ RocketChat._setUsername = (userId, username) ->
# If first time setting username, send Enrollment Email
if not previousUsername and user.emails?.length > 0 and RocketChat.settings.get 'Accounts_Enrollment_Email'
Accounts.sendEnrollmentEmail(user._id)
try
if not previousUsername and user.emails?.length > 0 and RocketChat.settings.get 'Accounts_Enrollment_Email'
Accounts.sendEnrollmentEmail(user._id)
catch error
# Username is available; if coming from old username, update all references
if previousUsername
......
......@@ -81,10 +81,14 @@ Template.loginForm.events
if instance.state.get() is 'forgot-password'
Meteor.call 'sendForgotPasswordEmail', s.trim(formData.email), (err, result) ->
RocketChat.Button.reset(button)
RocketChat.callbacks.run('userForgotPasswordEmailRequested');
toastr.success t('We_have_sent_password_email')
instance.state.set 'login'
if err
handleError(err)
instance.state.set 'login'
else
RocketChat.Button.reset(button)
RocketChat.callbacks.run('userForgotPasswordEmailRequested');
toastr.success t('We_have_sent_password_email')
instance.state.set 'login'
return
if instance.state.get() is 'register'
......
......@@ -6,6 +6,10 @@ Meteor.methods
user = RocketChat.models.Users.findOneByEmailAddress s.trim(email)
if user?
Accounts.sendVerificationEmail(user._id, s.trim(email))
try
Accounts.sendVerificationEmail(user._id, s.trim(email))
catch error
throw new Meteor.Error 'error-email-send-failed', 'Error trying to send email: ' + error.message, { method: 'registerUser', message: error.message }
return true
return false
......@@ -12,7 +12,11 @@ Meteor.methods
email = _.find _.pluck(user.emails || [], 'address'), (userEmail) ->
return regex.test(userEmail)
Accounts.sendResetPasswordEmail(user._id, email)
try
Accounts.sendResetPasswordEmail(user._id, email)
catch error
throw new Meteor.Error 'error-email-send-failed', 'Error trying to send email: ' + error.message, { method: 'registerUser', message: error.message }
return true
return false
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment