From 30ccaed2af5d4d3e0ca1f2ebeb9836a03c9dc3da Mon Sep 17 00:00:00 2001
From: xamgore <xamgore@ya.ru>
Date: Sat, 11 Jun 2016 00:22:40 +0300
Subject: [PATCH] Reformat code

---
 .../application/classes/Model/Account.php       |  2 +-
 ~dev_rating/application/classes/User.php        | 17 ++++++++---------
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/~dev_rating/application/classes/Model/Account.php b/~dev_rating/application/classes/Model/Account.php
index 3ba2085ff..6309c7bcf 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 5cfde79c0..8527d3028 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;
     }
-- 
GitLab