mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 05:37:32 +02:00
Github added to social logins.
This commit is contained in:
@@ -1469,6 +1469,27 @@ $social_logins = array (
|
||||
"AOL" => array (
|
||||
"enabled" => true
|
||||
),
|
||||
|
||||
"Facebook" => array (
|
||||
"enabled" => true,
|
||||
"keys" => array ( "id" => "", "secret" => "" ),
|
||||
"trustForwarded" => false,
|
||||
// A comma-separated list of permissions you want to request from the user. See the Facebook docs for a full list of available permissions: http://developers.facebook.com/docs/reference/api/permissions.
|
||||
"scope" => "",
|
||||
|
||||
// The display context to show the authentication page. Options are: page, popup, iframe, touch and wap. Read the Facebook docs for more details: http://developers.facebook.com/docs/reference/dialogs#display. Default: page
|
||||
"display" => ""
|
||||
),
|
||||
|
||||
"Foursquare" => array (
|
||||
"enabled" => true,
|
||||
"keys" => array ( "id" => "", "secret" => "" )
|
||||
),
|
||||
|
||||
"Github" => array (
|
||||
"enabled" => true,
|
||||
"keys" => array ( "key" => "", "secret" => "" )
|
||||
),
|
||||
|
||||
"Google" => array (
|
||||
"enabled" => true,
|
||||
@@ -1476,42 +1497,36 @@ $social_logins = array (
|
||||
"scope" => ""
|
||||
),
|
||||
|
||||
"Facebook" => array (
|
||||
"LinkedIn" => array (
|
||||
"enabled" => true,
|
||||
"keys" => array ( "id" => "", "secret" => "" ),
|
||||
|
||||
// A comma-separated list of permissions you want to request from the user. See the Facebook docs for a full list of available permissions: http://developers.facebook.com/docs/reference/api/permissions.
|
||||
"scope" => "",
|
||||
|
||||
// The display context to show the authentication page. Options are: page, popup, iframe, touch and wap. Read the Facebook docs for more details: http://developers.facebook.com/docs/reference/dialogs#display. Default: page
|
||||
"display" => ""
|
||||
"keys" => array ( "key" => "", "secret" => "" )
|
||||
),
|
||||
|
||||
// windows live
|
||||
"Live" => array (
|
||||
"enabled" => true,
|
||||
"keys" => array ( "id" => "", "secret" => "" )
|
||||
),
|
||||
|
||||
|
||||
"MySpace" => array (
|
||||
"enabled" => true,
|
||||
"keys" => array ( "key" => "", "secret" => "" )
|
||||
),
|
||||
|
||||
|
||||
"Twitter" => array (
|
||||
"enabled" => true,
|
||||
"keys" => array ( "key" => "", "secret" => "" )
|
||||
),
|
||||
|
||||
|
||||
|
||||
// windows live
|
||||
"Live" => array (
|
||||
"enabled" => true,
|
||||
"keys" => array ( "id" => "", "secret" => "" )
|
||||
),
|
||||
|
||||
|
||||
"MySpace" => array (
|
||||
"enabled" => true,
|
||||
"keys" => array ( "key" => "", "secret" => "" )
|
||||
),
|
||||
|
||||
|
||||
"LinkedIn" => array (
|
||||
"enabled" => true,
|
||||
"keys" => array ( "key" => "", "secret" => "" )
|
||||
),
|
||||
|
||||
"Foursquare" => array (
|
||||
"enabled" => true,
|
||||
"keys" => array ( "id" => "", "secret" => "" )
|
||||
)
|
||||
|
||||
);
|
||||
|
||||
|
||||
@@ -1523,7 +1538,8 @@ $social_external = array(
|
||||
"Google" => "https://code.google.com/apis/console/",
|
||||
"Live" => "https://manage.dev.live.com/ApplicationOverview.aspx",
|
||||
"LinkedIn" => "https://www.linkedin.com/secure/developer",
|
||||
"Foursquare" => "https://www.foursquare.com/oauth/"
|
||||
"Foursquare" => "https://www.foursquare.com/oauth/",
|
||||
"Github" => "https://github.com/settings/applications/new",
|
||||
);
|
||||
|
||||
|
||||
|
80
e107_handlers/hybridauth/Hybrid/Providers/GitHub.php
Normal file
80
e107_handlers/hybridauth/Hybrid/Providers/GitHub.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/*!
|
||||
* HybridAuth
|
||||
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
|
||||
* (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Hybrid_Providers_GitHub
|
||||
*/
|
||||
class Hybrid_Providers_GitHub extends Hybrid_Provider_Model_OAuth2
|
||||
{
|
||||
// default permissions
|
||||
// (no scope) => public read-only access (includes public user profile info, public repo info, and gists).
|
||||
public $scope = "";
|
||||
|
||||
/**
|
||||
* IDp wrappers initializer
|
||||
*/
|
||||
function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
|
||||
// Provider api end-points
|
||||
$this->api->api_base_url = "https://api.github.com/";
|
||||
$this->api->authorize_url = "https://github.com/login/oauth/authorize";
|
||||
$this->api->token_url = "https://github.com/login/oauth/access_token";
|
||||
}
|
||||
|
||||
/**
|
||||
* load the user profile from the IDp api client
|
||||
*/
|
||||
function getUserProfile()
|
||||
{
|
||||
$data = $this->api->api( "user" );
|
||||
|
||||
if ( ! isset( $data->id ) ){
|
||||
throw new Exception( "User profile request failed! {$this->providerId} returned an invalid response.", 6 );
|
||||
}
|
||||
|
||||
$this->user->profile->identifier = @ $data->id;
|
||||
$this->user->profile->displayName = @ $data->name;
|
||||
$this->user->profile->description = @ $data->bio;
|
||||
$this->user->profile->photoURL = @ $data->avatar_url;
|
||||
$this->user->profile->profileURL = @ $data->html_url;
|
||||
$this->user->profile->email = @ $data->email;
|
||||
$this->user->profile->webSiteURL = @ $data->blog;
|
||||
$this->user->profile->region = @ $data->location;
|
||||
|
||||
if( empty($this->user->profile->displayName) ){
|
||||
$this->user->profile->displayName = @ $data->login;
|
||||
}
|
||||
|
||||
// request user emails from github api
|
||||
if( empty($data->email) ){
|
||||
try{
|
||||
$emails = $this->api->api("user/emails");
|
||||
|
||||
// fail gracefully, and let apps collect the email if not present
|
||||
if (is_array($emails)) {
|
||||
foreach ($emails as $email) {
|
||||
if ($email instanceof stdClass
|
||||
&& property_exists('primary', $email)
|
||||
&& true === $email->primary
|
||||
&& property_exists('email', $email)
|
||||
) {
|
||||
$this->user->profile->email = $email->email;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( GithubApiException $e ){
|
||||
throw new Exception( "User email request failed! {$this->providerId} returned an error: $e", 6 );
|
||||
}
|
||||
}
|
||||
|
||||
return $this->user->profile;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user