diff options
author | Brett Walker <brett@digitalmoksha.com> | 2017-09-12 17:39:38 +0200 |
---|---|---|
committer | Brett Walker <brett@digitalmoksha.com> | 2017-09-23 15:24:53 +0200 |
commit | 09726bdf446b4673d4f92bc9132a6e34f3a67160 (patch) | |
tree | 6ffc8b4f91e91efe3183913631791408008b7a7c /app/models/user.rb | |
parent | 30e3a49e23f8ce0c2a07b13addc45951d7fc6719 (diff) | |
download | gitlab-ce-09726bdf446b4673d4f92bc9132a6e34f3a67160.tar.gz |
small cleanup changes based on feedback
Diffstat (limited to 'app/models/user.rb')
-rw-r--r-- | app/models/user.rb | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index cdc7c8ad84a..5e1355662b6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -810,6 +810,10 @@ class User < ActiveRecord::Base avatar_path(args) || GravatarService.new.execute(email, size, scale, username: username) end + def primary_email_verified? + confirmed? && !temp_oauth_email? + end + def all_emails all_emails = [] all_emails << email unless temp_oauth_email? @@ -817,15 +821,15 @@ class User < ActiveRecord::Base all_emails end - def all_verified_emails + def verified_emails verified_emails = [] - verified_emails << email if confirmed? && !temp_oauth_email? - verified_emails.concat(emails.select {|e| e.confirmed?}.map(&:email)) + verified_emails << email if primary_email_verified? + verified_emails.concat(emails.where.not(confirmed_at: nil).pluck(:email)) verified_emails end - def verified_email?(email) - all_verified_emails.include?(email) + def verified_email?(check_email) + (email == check_email && primary_email_verified?) || verified_emails.include?(check_email) end def hook_attrs |