diff --git a/api/cora/request.php b/api/cora/request.php index a3a5bc6..8295b31 100644 --- a/api/cora/request.php +++ b/api/cora/request.php @@ -322,7 +322,7 @@ final class request { 'ip_address' => ip2long($_SERVER['REMOTE_ADDR']), 'timestamp' => date('Y-m-d H:i:s', intval($this->begin_timestamp)), 'request' => $this->request, - 'response' => ($user['debug'] === true) ? $this->response : null, + 'response' => ($user !== null && $user['debug'] === true) ? $this->response : null, 'total_time' => $this->total_time, 'query_count' => $database->get_query_count(), 'query_time' => $database->get_query_time(), diff --git a/api/user.php b/api/user.php index f2060af..0c4c8f9 100644 --- a/api/user.php +++ b/api/user.php @@ -138,7 +138,9 @@ class user extends cora\crud { return; } - return $this->session->delete(); + $this->session->delete(); + + header('Location: https://auth.ecobee.com/logout?federated&client_id=' . $this->setting->get('ecobee_client_id') . '&returnTo=' . str_replace('app.', '', $this->setting->get('beestat_root_uri'))); } /** diff --git a/index.php b/index.php index e039440..31e2e9a 100644 --- a/index.php +++ b/index.php @@ -25,7 +25,7 @@ // If you're not logged in, just take you directly to the ecobee login page. if(isset($_COOKIE['session_key']) === false) { - header('Location: http://' . $_SERVER['HTTP_HOST'] . '/api/?resource=ecobee&method=authorize&arguments={}&api_key=' . $setting->get('beestat_api_key_local')); + header('Location: https://' . $_SERVER['HTTP_HOST'] . '/api/?resource=ecobee&method=authorize&arguments={}&api_key=' . $setting->get('beestat_api_key_local')); die(); } diff --git a/js/component/header.js b/js/component/header.js index c6763b7..30bba58 100644 --- a/js/component/header.js +++ b/js/component/header.js @@ -196,11 +196,10 @@ beestat.component.header.prototype.decorate_ = function(parent) { .set_text('Log Out') .set_icon('exit_to_app') .set_callback(function() { - new beestat.api() - .set_callback(function() { - window.location.href = window.location.href.replace('app.', ''); - }) - .add_call('user', 'log_out') - .send(); + window.location.replace( + window.location.href + + 'api/?resource=user&method=log_out&arguments={}&api_key=' + + window.beestat_api_key_local + ); })); };