DEV: Explicitly define primary_email_verified? method for managed authenticators (#19127)

We're going to change the default return value of the `primary_email_verified?` method of `Auth::ManagedAuthenticator` to false, so we need to explicitly define the method on authenticators to return true where it makes sense to do so.

Internal topic: t/82084.
This commit is contained in:
Osama Sayegh 2022-11-24 06:46:06 +03:00 committed by GitHub
parent 274b21663e
commit 65f57a4d05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 0 deletions

View File

@ -70,4 +70,9 @@ class Auth::DiscordAuthenticator < Auth::ManagedAuthenticator
super
end
# the `info` block above only picks the email from Discord API if it's verified
def primary_email_verified?(auth_token)
true
end
end

View File

@ -25,4 +25,10 @@ class Auth::FacebookAuthenticator < Auth::ManagedAuthenticator
scope: "email"
end
# facebook doesn't return unverified email addresses so it's safe to assume
# whatever email we get from them is verified
# https://developers.facebook.com/docs/graph-api/reference/user/
def primary_email_verified?(auth_token)
true
end
end

View File

@ -57,4 +57,10 @@ class Auth::GithubAuthenticator < Auth::ManagedAuthenticator
},
scope: "user:email"
end
# the omniauth-github gem only picks up the primary email if it's verified:
# https://github.com/omniauth/omniauth-github/blob/0ac46b59ccdabd4cbe5be4a665df269355081915/lib/omniauth/strategies/github.rb#L58-L61
def primary_email_verified?(auth_token)
true
end
end

View File

@ -23,4 +23,10 @@ class Auth::TwitterAuthenticator < Auth::ManagedAuthenticator
strategy.options[:consumer_secret] = SiteSetting.twitter_consumer_secret
}
end
# twitter doesn't return unverfied email addresses in the API
# https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/manage-account-settings/api-reference/get-account-verify_credentials
def primary_email_verified?(auth_token)
true
end
end