소셜로그인 수정

This commit is contained in:
thisgun committed 2017-10-26 10:19:49 +09:00
1 parent 1824cf0f27
commit 23bf0d6a17
6 files changed
+82 -29

No files matched your search

+10
View File
@@ -6,6 +6,16 @@ $g5['social_profile_table'] = G5_TABLE_PREFIX.'member_social_profiles';
//플러그인 폴더 이름 및 스킨 폴더 이름
define('G5_SOCIAL_LOGIN_DIR', 'social');
// 소셜로그인 login_start 파라미터 이름입니다. 기본값은 hauth.start
define('G5_SOCIAL_LOGIN_START_PARAM', 'hauth.start');
// 소셜로그인 login_done 파라미터 이름입니다. 기본값은 hauth.done
define('G5_SOCIAL_LOGIN_DONE_PARAM', 'hauth.done');
// 소셜로그인 G5_SOCIAL_LOGIN_URL 값의 끝에 해당 문자열을 더합니다.
define('G5_SOCIAL_LOGIN_ADD_URL', '/');
define('G5_SOCIAL_LOGIN_PATH', G5_PLUGIN_PATH.'/'.G5_SOCIAL_LOGIN_DIR);
define('G5_SOCIAL_LOGIN_URL', G5_PLUGIN_URL.'/'.G5_SOCIAL_LOGIN_DIR);
+1
View File
@@ -1,4 +1,5 @@
<?php
if (!defined('_GNUBOARD_')) exit;
/**
* HybridAuth
+13 -1
View File
@@ -80,7 +80,19 @@ function social_login_get_provider_adapter( $provider )
$newsession = $g5['hybrid_auth']->getSessionData();
return $g5['hybrid_auth']->authenticate($provider);
if( defined('G5_SOCIAL_LOGIN_START_PARAM') && G5_SOCIAL_LOGIN_START_PARAM === 'hauth.start' && G5_SOCIAL_LOGIN_DONE_PARAM === 'hauth.done' ){
return $g5['hybrid_auth']->authenticate($provider);
}
$base_url = G5_SOCIAL_LOGIN_URL.G5_SOCIAL_LOGIN_ADD_URL;
$hauth_time = time();
$connect_data = array(
'login_start' => $base_url . ( strpos($base_url, '?') ? '&' : '?' ) . G5_SOCIAL_LOGIN_START_PARAM.'='.$provider.'&hauth.time='.$hauth_time,
'login_done' => $base_url . ( strpos($base_url, '?') ? '&' : '?' ) . G5_SOCIAL_LOGIN_DONE_PARAM.'='.$provider,
);
return $g5['hybrid_auth']->authenticate($provider, $connect_data);
}
function social_before_join_check($url=''){
+25 -25
View File
@@ -1,32 +1,32 @@
<?php
if (!defined('_GNUBOARD_')) exit;
//https://hybridauth.github.io/hybridauth/userguide/tuts/change-hybridauth-endpoint-url.html
class G5_Hybrid_Endpoint extends Hybrid_Endpoint
{
protected function processAuthStart(){
try {
parent::processAuthStart();
}
catch( Exception $e ){
$this->dieError( "412 Precondition Failed", $e->getMessage(), $e );
}
class G5_Hybrid_Authentication {
public static function hybridauth_endpoint() {
require_once( G5_SOCIAL_LOGIN_PATH.'/Hybrid/Auth.php' );
require_once( G5_SOCIAL_LOGIN_PATH.'/Hybrid/Endpoint.php' );
require_once( G5_SOCIAL_LOGIN_PATH.'/includes/g5_endpoint_class.php' );
if( defined('G5_SOCIAL_LOGIN_START_PARAM') && G5_SOCIAL_LOGIN_START_PARAM !== 'hauth.start' && isset($_REQUEST[G5_SOCIAL_LOGIN_START_PARAM]) ){
$_REQUEST['hauth.start'] = preg_replace('/[^a-zA-Z0-9\-\._]/i', '', $_REQUEST[G5_SOCIAL_LOGIN_START_PARAM]);
}
if( defined('G5_SOCIAL_LOGIN_DONE_PARAM') && G5_SOCIAL_LOGIN_DONE_PARAM !== 'hauth.done' && isset($_REQUEST[G5_SOCIAL_LOGIN_DONE_PARAM]) ){
$_REQUEST['hauth.done'] = preg_replace('/[^a-zA-Z0-9\-\._]/i', '', $_REQUEST[G5_SOCIAL_LOGIN_DONE_PARAM]);
}
/*
$key = 'hauth.' . $action; // either `hauth_start` or `hauth_done`
$_REQUEST[ $key ] = $provider; // provider will be something like `facebook` or `google`
*/
G5_Hybrid_Endpoint::process();
}
protected function processAuthDone()
{
try {
parent::processAuthDone();
}
catch( Exception $e ){
$this->dieError( "410 Gone", $e->getMessage(), $e );
}
}
public function dieError( $code, $message, $e )
{
$get_error = $message;
include_once(G5_SOCIAL_LOGIN_PATH.'/error.php');
die();
}
}
?>
@@ -0,0 +1,32 @@
<?php
if (!defined('_GNUBOARD_')) exit;
class G5_Hybrid_Endpoint extends Hybrid_Endpoint
{
protected function processAuthStart(){
try {
parent::processAuthStart();
}
catch( Exception $e ){
$this->dieError( "412 Precondition Failed", $e->getMessage(), $e );
}
}
protected function processAuthDone()
{
try {
parent::processAuthDone();
}
catch( Exception $e ){
$this->dieError( "410 Gone", $e->getMessage(), $e );
}
}
public function dieError( $code, $message, $e )
{
$get_error = $message;
include_once(G5_SOCIAL_LOGIN_PATH.'/error.php');
die();
}
}
?>
+1 -3
View File
@@ -10,8 +10,6 @@
// ------------------------------------------------------------------------
include_once('_common.php');
require_once( "Hybrid/Auth.php" );
require_once( "Hybrid/Endpoint.php" );
require_once( "includes/g5_endpoint.php" );
G5_Hybrid_Endpoint::process();
G5_Hybrid_Authentication::hybridauth_endpoint();