Fixes to make SO login work. GitHub now works also (was a FF plugin bug)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<?php namespace SocialNorm\GitHub;
|
||||
|
||||
use SocialNorm\Exceptions\AuthNotUsableException;
|
||||
use SocialNorm\Exceptions\InvalidAuthorizationCodeException;
|
||||
use SocialNorm\Providers\OAuth2Provider;
|
||||
|
||||
@@ -15,7 +16,8 @@ class GitHubProvider extends OAuth2Provider
|
||||
protected $headers = [
|
||||
'authorize' => [],
|
||||
'access_token' => [
|
||||
'Accept' => 'application/json'
|
||||
'Accept' => 'application/json',
|
||||
'Content-Type' => 'application/x-www-form-urlencoded'
|
||||
],
|
||||
'user_details' => [
|
||||
'Accept' => 'application/vnd.github.v3'
|
||||
@@ -72,10 +74,13 @@ class GitHubProvider extends OAuth2Provider
|
||||
protected function getPrimaryEmail($emails)
|
||||
{
|
||||
foreach ($emails as $email) {
|
||||
if ($email['primary']) {
|
||||
if ($email['primary'] && $email['verified']) {
|
||||
return $email['email'];
|
||||
}
|
||||
}
|
||||
if (!$emails[0]['verified']) {
|
||||
throw new AuthNotUsableException("No verified e-mail.");
|
||||
}
|
||||
return $emails[0]['email'];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user