Skip to content
Snippets Groups Projects
Commit 30ccaed2 authored by xamgore's avatar xamgore
Browse files

Reformat code

parent 50e4a206
Branches
Tags
No related merge requests found
......@@ -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)
......
......@@ -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;
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment