Fixed GitHub e-mail address lookup

This commit is contained in:
Lucas Bartholemy 2016-05-25 17:19:37 +02:00
parent 6cc7e4b185
commit e0e25ea54b

View File

@ -14,6 +14,27 @@ namespace humhub\modules\user\authclient;
class GitHub extends \yii\authclient\clients\GitHub
{
/**
* @inheritdoc
*/
protected function normalizeUserAttributes($attributes)
{
if (!isset($attributes['email'])) {
$emails = $this->api('user/emails', 'GET');
if (is_array($emails)) {
foreach ($emails as $email) {
if ($email['primary'] == 1 && $email['verified'] == 1) {
$attributes['email'] = $email['email'];
break;
}
}
}
}
return parent::normalizeUserAttributes($attributes);
}
/**
* @inheritdoc
*/