Update api.socialhub.php

This commit is contained in:
Namhyeon Go 2018-09-27 02:37:46 +09:00 committed by GitHub
parent 4f0e96f456
commit 60c4ceef8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,16 +24,15 @@ if(!empty($api_session_id)) {
"storage_type" => "session" "storage_type" => "session"
)); ));
if(!$fr) { if(!$fr) {
set_error("maybe, your session is expired."); $api_session_id = ""; // renew api session id
show_errors();
} else { } else {
$session_data = json_decode($fr); $session_data = json_decode($fr);
$provider = get_value_in_array("provider", $session_data, ""); $provider = get_property_value("provider", $session_data);
$action = get_value_in_array("action", $session_data, ""); $action = get_property_value("action", $session_data);
$redirect_url = get_value_in_array("redirect_url", $session_data, ""); $redirect_url = get_property_value("redirect_url", $session_data);
$user_id = get_value_in_array("user_id", $session_data, ""); $user_id = get_property_value("user_id", $session_data);
$connection_id = get_value_in_array("connection_id", $session_data, ""); $connection_id = get_property_value("connection_id", $session_data);
$message = get_value_in_array("message", $session_data, ""); $message = get_property_value("message", $session_data);
} }
} }
@ -56,7 +55,7 @@ $hauth = new Hybrid_Auth($configfile);
// try session restore // try session restore
$session_flag = false; $session_flag = false;
if(empty($connection_id)) { if(!empty($connection_id)) {
$hauth_session = get_stored_hybridauth_session($connection_id); $hauth_session = get_stored_hybridauth_session($connection_id);
if(!empty($hauth_session)) { if(!empty($hauth_session)) {
try { try {
@ -73,7 +72,6 @@ if(check_hybridauth()) {
$hauth_session = $hauth->getSessionData(); $hauth_session = $hauth->getSessionData();
$connection_id = store_hybridauth_session($hauth_session, $user_id); $connection_id = store_hybridauth_session($hauth_session, $user_id);
if($connection_id) { if($connection_id) {
$hauth_profile = $hauth_adapter->getUserProfile();
$session_flag = true; $session_flag = true;
} }
} }
@ -81,13 +79,13 @@ if(check_hybridauth()) {
// save session // save session
$api_session_id = get_hashed_text(make_random_id(32)); $api_session_id = get_hashed_text(make_random_id(32));
$session_data = array( $session_data = array(
"api_session_id" => $api_session_id,
"provider" => $provider, "provider" => $provider,
"action" => $action, "action" => $action,
"redirect_url" => $redirect_url, "redirect_url" => $redirect_url,
"user_id" => $user_id, "user_id" => $user_id,
"connection_id" => $connection_id, "connection_id" => $connection_id,
"message" => $message, "message" => $message
"profile" => $hauth_profile
); );
$fw = write_storage_file(json_encode($session_data), array( $fw = write_storage_file(json_encode($session_data), array(
"storage_type" => "session", "storage_type" => "session",
@ -122,6 +120,9 @@ if(!$session_flag) {
), false)); ), false));
} }
// get user profile
$hauth_profile = $hauth_adapter->getUserProfile();
// do action // do action
$context = array(); $context = array();
switch($action) { switch($action) {