From 46ec499cf7b4b5ef9cd5d6db4759e25b0bd8bc75 Mon Sep 17 00:00:00 2001 From: PavelBegunkov <asml.Silence@gmail.com> Date: Thu, 27 Nov 2014 22:48:57 +0300 Subject: [PATCH] mad session --- .../classes/Controller/Handler/Session.php | 22 +++++++++---------- .../modules/account/classes/Kohana/User.php | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/~dev_rating/application/classes/Controller/Handler/Session.php b/~dev_rating/application/classes/Controller/Handler/Session.php index 1b4f7dce9..6cf985196 100644 --- a/~dev_rating/application/classes/Controller/Handler/Session.php +++ b/~dev_rating/application/classes/Controller/Handler/Session.php @@ -1,23 +1,23 @@ <?php defined('SYSPATH') or die('No direct script access.'); class Controller_Handler_Session extends Controller_Handler { + + protected $_session; public function before() { - $this->setAccessLevel(self::ACCESS_USER); + $this->setAccessLevel(self::ACCESS_ANYBODY); parent::before(); + $this->_session = Session::instance(); } public function action_getSessionTime() { - $session = Session::instance(); - if ($session->get('LoggedIn')) { - $dif_time = $session->get('dif_time'); + + if (User::instance()->isSignedIn() && $this->_session) { + $dif_time = $this->_session->get('dif_time'); $timeout = User::SESSION_LIFETIME; $remain = $timeout - $dif_time; - if ($remain <= 0) { - $this->completeSignOut(); - } - $session->set('last_time', - $session->get('last_time') - $dif_time); + $this->_session->set('last_time', + $this->_session->get('last_time') - $dif_time); } else { $remain = 0; } @@ -25,8 +25,8 @@ class Controller_Handler_Session extends Controller_Handler { } public function action_closeSession() { - if ($session->get('LoggedIn')) { - $this->completeSignOut(); + if (User::instance()->isSignedIn()) { + User::instance()->completeSignOut(); } $this->response->body(json_encode(0)); } diff --git a/~dev_rating/modules/account/classes/Kohana/User.php b/~dev_rating/modules/account/classes/Kohana/User.php index 5f36cbcf3..8dc9b9d5f 100644 --- a/~dev_rating/modules/account/classes/Kohana/User.php +++ b/~dev_rating/modules/account/classes/Kohana/User.php @@ -8,7 +8,7 @@ class Kohana_User implements ArrayAccess { protected $_model; protected $_userInfo; - const SESSION_LIFETIME = 600; //seconds + const SESSION_LIFETIME = 20; //seconds /** * Вовзращает экземпляр класса (singleton-паттерн) -- GitLab