mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-11 18:26:50 +00:00
Avoid using exception but simply errors attribute contained in object
This commit is contained in:
@@ -9,7 +9,9 @@ module ManagerInvitations
|
||||
new_user.reset_password_token = Devise.friendly_token
|
||||
# Same time as used in Devise's lib/devise/models/recoverable.rb.
|
||||
new_user.reset_password_sent_at = Time.now.utc
|
||||
new_user.save!
|
||||
new_user.save
|
||||
|
||||
return new_user unless new_user.valid? # Return early if user is invalid.
|
||||
|
||||
enterprise.users << new_user
|
||||
EnterpriseMailer.manager_invitation(@enterprise, new_user).deliver_later
|
||||
|
||||
@@ -20,13 +20,13 @@ class InviteManagerReflex < ApplicationReflex
|
||||
return
|
||||
end
|
||||
|
||||
begin
|
||||
new_user = create_new_manager(email, enterprise)
|
||||
new_user = create_new_manager(email, enterprise)
|
||||
|
||||
if new_user.valid?
|
||||
locals[:success] = true
|
||||
locals[:email] = new_user.email
|
||||
rescue StandardError => e
|
||||
@error = e.message
|
||||
locals[:error] = @error || I18n.t('admin.enterprises.invite_manager.error')
|
||||
else
|
||||
locals[:error] = new_user.errors.full_messages.to_sentence ||
|
||||
I18n.t('admin.enterprises.invite_manager.error')
|
||||
end
|
||||
|
||||
return_morph(locals)
|
||||
|
||||
Reference in New Issue
Block a user