Update api.socialhub.php

This commit is contained in:
Namhyeon Go 2018-09-27 00:56:51 +09:00 committed by GitHub
parent 684717ea0a
commit 41f9bb665c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,6 +16,9 @@ $redirect_url = get_requested_value("redirect_url");
$user_id = get_reqeusted_value("user_id");
$connection_id = get_requested_value("connection_id");
$hauth_adapter = null;
$hauth_session = null;
// check hauth parameters
$is_hauth = false;
foreach($requests['_ALL'] as $k=>$v) {
@ -36,7 +39,7 @@ $hauth = new Hybrid_Auth($configfile);
// try session restore
$session_flag = false;
if(empty($connection_id)) {
$hauth_session = get_stored_hybridauth_session($connection_id);
$hauth_session = get_stored_hybridauth_session($connection_id);
if(!empty($hauth_session)) {
try {
$hauth->restoreSessionData($hauth_session);
@ -52,17 +55,27 @@ if(!$session_flag) {
try {
$adapter = $hybridauth->authenticate($provider);
} catch(Exception $e) {
// if failed authenticate
redirect_uri(get_route_link("api.socialhub", array(
"provider" => $provider,
"action" => $action,
"redirect_url" => $redirect_url,
"user_id" => $user_id
), false));
// nothing
}
$hauth_session = $hauth->getSessionData();
$connection_id = store_hybridauth_session($hauth_session, $user_id);
if(!is_null($hauth_adapter)) {
$hauth_session = $hauth->getSessionData();
$connection_id = store_hybridauth_session($hauth_session, $user_id);
if($connection_id) {
$session_flag = true;
}
}
}
// if failed authenticate
if(!$session_flag) {
// if failed authenticate
redirect_uri(get_route_link("api.socialhub", array(
"provider" => $provider,
"action" => $action,
"redirect_url" => $redirect_url,
"user_id" => $user_id
), false));
}
// do action
@ -74,5 +87,6 @@ switch($action) {
case "new":
break;
case "login":
break;
}