Fixed login/logout issue

This commit is contained in:
Gregorio Chiko Putra 2017-10-26 09:44:43 +07:00
parent d2327c92dd
commit b3c27d513d
4 changed files with 33 additions and 31 deletions

View File

@ -109,8 +109,8 @@ class Home
if (isset($_SERVER['HTTP_CLIENT']) && $_SERVER['HTTP_CLIENT'] == 'api') { if (isset($_SERVER['HTTP_CLIENT']) && $_SERVER['HTTP_CLIENT'] == 'api') {
echo json_encode($logged_out);die(); echo json_encode($logged_out);die();
} }
Session::flash('info', $info); // Session::flash('info', $info);
Redirect::to('/'); // Redirect::to('/');
} }
public function register() public function register()
@ -193,21 +193,21 @@ class Home
public function delete($id = '') public function delete($id = '')
{ {
// if ($id) { if ($id) {
// $uid = $id; $uid = $id;
// } elseif (isset($_SERVER['HTTP_X_TOKEN'])) { // } elseif (isset($_SERVER['HTTP_X_TOKEN'])) {
// $token = Token::fetch($_SERVER['HTTP_X_TOKEN']); // $token = Token::fetch($_SERVER['HTTP_X_TOKEN']);
// if ($token == '') { // if ($token == '') {
// throw new \Exception("Token invalid"); // throw new \Exception("Token invalid");
// } // }
// $uid = $token['uid']; // $uid = $token['uid'];
// } elseif (isset($_SERVER['HTTP_X_QUERY'])) { } elseif (isset($_SERVER['HTTP_X_QUERY'])) {
$query_string = $_SERVER['HTTP_X_QUERY']; $query_string = $_SERVER['HTTP_X_QUERY'];
$exploded = explode('&', $query_string); $exploded = explode('&', $query_string);
$uid = $exploded[1]; $uid = $exploded[1];
$uid = explode('=', $uid); $uid = explode('=', $uid);
$uid = $uid[1]; $uid = $uid[1];
// } }
$ip = isset($_SERVER['HTTP_X_FORWADED_FOR']) ? $_SERVER['HTTP_X_FORWADED_FOR'] : $_SERVER['REMOTE_ADDR']; $ip = isset($_SERVER['HTTP_X_FORWADED_FOR']) ? $_SERVER['HTTP_X_FORWADED_FOR'] : $_SERVER['REMOTE_ADDR'];

View File

@ -64,7 +64,7 @@ class Router
} }
} }
if ($url != '/login' && $url != '/') { if ($url != '/login' || $url != '/') {
$query_string = $this->getQueryStringVariable($url); $query_string = $this->getQueryStringVariable($url);
if ($query_string) { if ($query_string) {
$sessid = explode('=', $query_string[0]); $sessid = explode('=', $query_string[0]);
@ -87,6 +87,7 @@ class Router
$obj = $this->getNamespace($obj); $obj = $this->getNamespace($obj);
if (is_array($record)) { if (is_array($record)) {
$obj = new $obj(); $obj = new $obj();
header('client: api');
$obj->logout($record['uid']); $obj->logout($record['uid']);
die(); die();
} else { } else {
@ -103,8 +104,8 @@ class Router
$obj = $this->getNamespace($obj); $obj = $this->getNamespace($obj);
$obj = new $obj(); $obj = new $obj();
$obj->logout($record['uid']); $obj->logout($record['uid']);
header('Location: /'); // header('Location: /');
die(); // die();
} }
} }
} }

View File

@ -15,6 +15,7 @@ require('../css/index.css')
var root = document.body var root = document.body
var page = cookie.get('signal') var page = cookie.get('signal')
console.log(page);
if (page == '') { if (page == '') {
m.mount(root, header) m.mount(root, header)

File diff suppressed because one or more lines are too long