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') {
echo json_encode($logged_out);die();
}
Session::flash('info', $info);
Redirect::to('/');
// Session::flash('info', $info);
// Redirect::to('/');
}
public function register()
@ -193,21 +193,21 @@ class Home
public function delete($id = '')
{
// if ($id) {
// $uid = $id;
if ($id) {
$uid = $id;
// } elseif (isset($_SERVER['HTTP_X_TOKEN'])) {
// $token = Token::fetch($_SERVER['HTTP_X_TOKEN']);
// if ($token == '') {
// throw new \Exception("Token invalid");
// }
// $uid = $token['uid'];
// } elseif (isset($_SERVER['HTTP_X_QUERY'])) {
} elseif (isset($_SERVER['HTTP_X_QUERY'])) {
$query_string = $_SERVER['HTTP_X_QUERY'];
$exploded = explode('&', $query_string);
$uid = $exploded[1];
$uid = explode('=', $uid);
$uid = $uid[1];
// }
}
$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);
if ($query_string) {
$sessid = explode('=', $query_string[0]);
@ -87,6 +87,7 @@ class Router
$obj = $this->getNamespace($obj);
if (is_array($record)) {
$obj = new $obj();
header('client: api');
$obj->logout($record['uid']);
die();
} else {
@ -103,8 +104,8 @@ class Router
$obj = $this->getNamespace($obj);
$obj = new $obj();
$obj->logout($record['uid']);
header('Location: /');
die();
// header('Location: /');
// die();
}
}
}

View File

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

File diff suppressed because one or more lines are too long