|
@ -24,19 +24,18 @@ class User |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (!self::$user = self::getByLogin(strtolower($login)) ) { |
|
|
|
|
|
|
|
|
self::setInfo(self::getByLogin(strtolower($login))); |
|
|
|
|
|
if (!self::getInfo()) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (stripslashes(self::$user->pass) != $password) { |
|
|
if (stripslashes(self::$user->pass) != $password) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (!self::isActive(self::$user->id)) { |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
self::setSession(); |
|
|
|
|
|
|
|
|
self::setSession(); |
|
|
|
|
|
Load::model('UserData')->loginUpdate($login); |
|
|
|
|
|
|
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -54,6 +53,7 @@ class User |
|
|
{ |
|
|
{ |
|
|
if (Env::getCookie(session_name())) { //есть сессия
|
|
|
if (Env::getCookie(session_name())) { //есть сессия
|
|
|
session_start(); |
|
|
session_start(); |
|
|
|
|
|
self::setInfo(Env::Session('user')); |
|
|
} elseif (Env::getCookie('login') && Env::getCookie('login_hash')) { |
|
|
} elseif (Env::getCookie('login') && Env::getCookie('login_hash')) { |
|
|
self::remember(); |
|
|
self::remember(); |
|
|
} |
|
|
} |
|
@ -71,7 +71,9 @@ class User |
|
|
|
|
|
|
|
|
static function remember() |
|
|
static function remember() |
|
|
{ |
|
|
{ |
|
|
if (! self::$user = self::getByLogin(Env::getCookie('login'))) { |
|
|
|
|
|
|
|
|
self::setInfo(self::getByLogin(Env::getCookie('login'))); |
|
|
|
|
|
|
|
|
|
|
|
if (!self::getInfo()) { |
|
|
self::logout(); |
|
|
self::logout(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -91,6 +93,11 @@ class User |
|
|
{ |
|
|
{ |
|
|
return Env::Session('user', self::$user); |
|
|
return Env::Session('user', self::$user); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static function setInfo($data) |
|
|
|
|
|
{ |
|
|
|
|
|
self::$user = $data; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
static function isGuest() |
|
|
static function isGuest() |
|
|
{ |
|
|
{ |
|
@ -102,9 +109,10 @@ class User |
|
|
return Load::model('UserData')->getByLogin($login); |
|
|
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); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
?>
|
|
|
?>
|