Browse Source

git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/trunk@23 4cb57b5f-5bbd-dd11-951b-001d605cbbc5

master
ejikharev 16 years ago
parent
commit
e66b8410a7
  1. 24
      classes/User.class.php

24
classes/User.class.php

@ -24,7 +24,8 @@ class User
return false;
}
if (!self::$user = self::getByLogin(strtolower($login)) ) {
self::setInfo(self::getByLogin(strtolower($login)));
if (!self::getInfo()) {
return false;
}
@ -32,11 +33,9 @@ class User
return false;
}
if (!self::isActive(self::$user->id)) {
return false;
}
self::setSession();
Load::model('UserData')->loginUpdate($login);
self::setSession();
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();
}
@ -92,6 +94,11 @@ class User
return Env::Session('user', self::$user);
}
static function setInfo($data)
{
self::$user = $data;
}
static function isGuest()
{
return ! (bool) Env::Session('user');
@ -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);
}
}
?>
Loading…
Cancel
Save