diff --git a/~dev_rating/application/classes/Model/Account.php b/~dev_rating/application/classes/Model/Account.php index 3ba2085ff21ee7ba10f411eb69e89e391cdb52ee..6309c7bcfd27fbcb200e5fe648d6ee8437b6fcb0 100644 --- a/~dev_rating/application/classes/Model/Account.php +++ b/~dev_rating/application/classes/Model/Account.php @@ -15,7 +15,7 @@ class Model_Account extends Model } public static function checkAuth($login, $password) { - $sql = "SELECT `SignIn`(:login, :pass) AS `ID`;"; + $sql = 'SELECT `SignIn`(:login, :pass) AS `ID`'; return DB::query(Database::SELECT, $sql) ->param(':login', $login) ->param(':pass', $password) diff --git a/~dev_rating/application/classes/User.php b/~dev_rating/application/classes/User.php index 5cfde79c032188c4cde799683bc944c270724519..8527d30280d88582e6eafa4e3509fd073fb17001 100644 --- a/~dev_rating/application/classes/User.php +++ b/~dev_rating/application/classes/User.php @@ -146,7 +146,7 @@ class User implements ArrayAccess return [false, 'login_exists']; } - $this->completeSignIn($id, $this->hash($password)); + $this->initSession($id, $this->hash($password)); return [true, 'ok']; } @@ -159,19 +159,18 @@ class User implements ArrayAccess * и false, если данные являются некорректными. */ public function signIn($login, $password) { - $id = (int)Model_Account::checkAuth($login, $password); - return $this->completeSignIn($id, $this->hash($password)); + $id = (int) Model_Account::checkAuth($login, $password); + return $this->initSession($id, $this->hash($password)); } - protected function completeSignIn($id, $passHash) - { - if ( $id <= 0 ) - return false; + protected function initSession($id, $passHash) { + if ($id <= 0) return false; $source = $id . Request::$user_agent . Request::$client_ip; $userHash = $this->hash($source) . $this->_config['hash_key']; $passwordHash = $this->hash($passHash . $this->_config['hash_key']); Cookie::set('userhash', $passwordHash); + $userInfo = Model_Account::with($id, $this->_general->SemesterID); $session = $this->_session; @@ -182,9 +181,9 @@ class User implements ArrayAccess $session->set('UserHash', $this->hash($userHash)); $session->set('PasswordHash', $passwordHash); $session->set('start_time', time()); - foreach($userInfo as $key => $value) { + + foreach ($userInfo as $key => $value) $session->set($key, $value); - } return true; }