summaryrefslogtreecommitdiff
path: root/app/models/user.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/user.rb')
-rw-r--r--app/models/user.rb14
1 files changed, 7 insertions, 7 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index c6b2baea8e8..7a9561a04ff 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -164,7 +164,7 @@ class User < ActiveRecord::Base
before_save :ensure_authentication_token, :ensure_incoming_email_token
before_save :ensure_user_rights_and_limits, if: :external_changed?
before_save :skip_reconfirmation!, if: ->(user) { user.email_changed? && user.read_only_attribute?(:email) }
- before_save :check_for_verified_email, if: ->(user) { user.email_changed? && !user.new_record?}
+ before_save :check_for_verified_email, if: ->(user) { user.email_changed? && !user.new_record? }
after_save :ensure_namespace_correct
after_destroy :post_destroy_hook
after_commit :update_emails_with_primary_email, on: :update, if: -> { previous_changes.key?('email') }
@@ -223,11 +223,6 @@ class User < ActiveRecord::Base
end
end
- # see if the new email is already a verified secondary email
- def check_for_verified_email
- skip_reconfirmation! if emails.find_by(email: self.email).try(:confirmed?)
- end
-
mount_uploader :avatar, AvatarUploader
has_many :uploads, as: :model, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
@@ -529,6 +524,11 @@ class User < ActiveRecord::Base
errors.add(:public_email, "is not an email you own") unless all_emails.include?(public_email)
end
+ # see if the new email is already a verified secondary email
+ def check_for_verified_email
+ skip_reconfirmation! if emails.confirmed.where(email: self.email).any?
+ end
+
# Note: the use of the Emails services will cause `saves` on the user object, running
# through the callbacks again and can have side effects, such as the `previous_changes`
# hash and `_was` variables getting munged.
@@ -843,7 +843,7 @@ class User < ActiveRecord::Base
def verified_email?(check_email)
downcased = check_email.downcase
- (email == downcased && primary_email_verified?) || emails.confirmed.where(email: downcased).exists?
+ email == downcased ? primary_email_verified? : emails.confirmed.where(email: downcased).exists?
end
def hook_attrs