Renames confirmed_oauth_email to oauth_email
Refactors the way oauth_email is used to cover more cases (fixes pending specs)
This commit is contained in:
@@ -52,16 +52,16 @@ class User < ActiveRecord::Base
|
||||
# Get the existing user by email if the provider gives us a verified email.
|
||||
def self.first_or_initialize_for_oauth(auth)
|
||||
oauth_email = auth.info.email
|
||||
confirmed_oauth_email = oauth_email if auth.info.verified || auth.info.verified_email
|
||||
oauth_user = User.find_by(email: confirmed_oauth_email) if confirmed_oauth_email.present?
|
||||
oauth_email_confirmed = auth.info.verified || auth.info.verified_email
|
||||
oauth_user = User.find_by(email: oauth_email) if oauth_email_confirmed
|
||||
|
||||
oauth_user || User.new(
|
||||
username: auth.info.name || auth.uid,
|
||||
email: oauth_email,
|
||||
confirmed_oauth_email: confirmed_oauth_email,
|
||||
oauth_email: oauth_email,
|
||||
password: Devise.friendly_token[0,20],
|
||||
terms_of_service: '1',
|
||||
confirmed_at: confirmed_oauth_email.present? ? DateTime.now : nil
|
||||
confirmed_at: oauth_email_confirmed ? DateTime.now : nil
|
||||
)
|
||||
end
|
||||
|
||||
@@ -174,11 +174,6 @@ class User < ActiveRecord::Base
|
||||
!erased? && !registering_with_oauth
|
||||
end
|
||||
|
||||
# Deactivates the email uniqueness validation when registering with oauth
|
||||
def email_changed?
|
||||
!registering_with_oauth && super
|
||||
end
|
||||
|
||||
def has_official_email?
|
||||
domain = Setting['email_domain_for_officials']
|
||||
!email.blank? && ( (email.end_with? "@#{domain}") || (email.end_with? ".#{domain}") )
|
||||
|
||||
Reference in New Issue
Block a user