Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/user.rb')
-rw-r--r--app/models/user.rb20
1 files changed, 11 insertions, 9 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 81316f81818..927ffa4d12b 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -756,15 +756,15 @@ class User < ApplicationRecord
end
def owns_notification_email
- return if temp_oauth_email?
+ return if new_record? || temp_oauth_email?
- errors.add(:notification_email, _("is not an email you own")) unless all_emails.include?(notification_email)
+ errors.add(:notification_email, _("is not an email you own")) unless verified_emails.include?(notification_email)
end
def owns_public_email
return if public_email.blank?
- errors.add(:public_email, _("is not an email you own")) unless all_emails.include?(public_email)
+ errors.add(:public_email, _("is not an email you own")) unless verified_emails.include?(public_email)
end
def owns_commit_email
@@ -1212,18 +1212,20 @@ class User < ApplicationRecord
all_emails
end
- def all_public_emails
- all_emails(include_private_email: false)
- end
-
- def verified_emails
+ def verified_emails(include_private_email: true)
verified_emails = []
verified_emails << email if primary_email_verified?
- verified_emails << private_commit_email
+ verified_emails << private_commit_email if include_private_email
verified_emails.concat(emails.confirmed.pluck(:email))
verified_emails
end
+ def public_verified_emails
+ emails = verified_emails(include_private_email: false)
+ emails << email unless temp_oauth_email?
+ emails.uniq
+ end
+
def any_email?(check_email)
downcased = check_email.downcase