From a9b31786971d83c193a1430df7c5c4550ba5aa6b Mon Sep 17 00:00:00 2001 From: Brett Walker Date: Mon, 11 Sep 2017 19:12:57 +0200 Subject: Make GPG signature verification work with non-primary email (#36959) --- app/models/user.rb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'app/models/user.rb') diff --git a/app/models/user.rb b/app/models/user.rb index 09c9b3250eb..cdc7c8ad84a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -817,6 +817,17 @@ class User < ActiveRecord::Base all_emails end + def all_verified_emails + verified_emails = [] + verified_emails << email if confirmed? && !temp_oauth_email? + verified_emails.concat(emails.select {|e| e.confirmed?}.map(&:email)) + verified_emails + end + + def verified_email?(email) + all_verified_emails.include?(email) + end + def hook_attrs { name: name, @@ -1041,10 +1052,6 @@ class User < ActiveRecord::Base ensure_rss_token! end - def verified_email?(email) - self.email == email - end - def sync_attribute?(attribute) return true if ldap_user? && attribute == :email -- cgit v1.2.1