Don't try to use mail attribute if invalid

pull/9560/head
Oliver Günther 3 years ago
parent 01d4c53578
commit 934a8b500c
No known key found for this signature in database
GPG Key ID: A3A8BDAD7C0C552C
  1. 8
      app/models/application_record.rb
  2. 2
      app/services/users/set_attributes_service.rb

@ -7,6 +7,14 @@ class ApplicationRecord < ::ActiveRecord::Base
saved_change_to_attribute?(:id) saved_change_to_attribute?(:id)
end end
##
# Returns whether the given attribute is free of errors
def valid_attribute?(attribute)
valid? # Ensure validations have run
errors[attribute].empty?
end
## ##
# Get the newest recently changed resource for the given record classes # Get the newest recently changed resource for the given record classes
# #

@ -42,7 +42,7 @@ module Users
def set_default_attributes(_params) def set_default_attributes(_params)
# Assign values other than mail to new_user when invited # Assign values other than mail to new_user when invited
if model.invited? && model.mail.present? if model.invited? && model.valid_attribute?(:mail)
::UserInvitation.assign_user_attributes model ::UserInvitation.assign_user_attributes model
end end

Loading…
Cancel
Save