diff --git a/classes/User.class.php b/classes/User.class.php index 4f7d32e..2ed5d74 100644 --- a/classes/User.class.php +++ b/classes/User.class.php @@ -24,19 +24,18 @@ class User return false; } - if (!self::$user = self::getByLogin(strtolower($login)) ) { + self::setInfo(self::getByLogin(strtolower($login))); + if (!self::getInfo()) { return false; } if (stripslashes(self::$user->pass) != $password) { return false; } - - if (!self::isActive(self::$user->id)) { - return false; - } - self::setSession(); + self::setSession(); + Load::model('UserData')->loginUpdate($login); + return true; } @@ -54,6 +53,7 @@ class User { if (Env::getCookie(session_name())) { //есть сессия session_start(); + self::setInfo(Env::Session('user')); } elseif (Env::getCookie('login') && Env::getCookie('login_hash')) { self::remember(); } @@ -71,7 +71,9 @@ class User static function remember() { - if (! self::$user = self::getByLogin(Env::getCookie('login'))) { + self::setInfo(self::getByLogin(Env::getCookie('login'))); + + if (!self::getInfo()) { self::logout(); } @@ -91,6 +93,11 @@ class User { return Env::Session('user', self::$user); } + + static function setInfo($data) + { + self::$user = $data; + } static function isGuest() { @@ -102,9 +109,10 @@ class User return Load::model('UserData')->getByLogin($login); } - static function isActive($user_id) + static function getById($id) { - return Load::model('UserActivate')->isActive($user_id); + return Load::model('UserData')->getById($id); } + } ?> \ No newline at end of file