@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | session_start(); |
| 77 | 77 | } |
| 78 | 78 | // Fix for phpunits |
| 79 | - if(!isset($_SESSION)) { |
|
| 79 | + if (!isset($_SESSION)) { |
|
| 80 | 80 | $_SESSION = []; |
| 81 | 81 | } |
| 82 | 82 | } |
@@ -136,12 +136,12 @@ discard block |
||
| 136 | 136 | { |
| 137 | 137 | $saved = true; |
| 138 | 138 | try { |
| 139 | - $admins = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true) ?: []; |
|
| 140 | - $admins[$user['username']]['hash'] = sha1($user['username'] . $user['password']); |
|
| 139 | + $admins = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true) ?: []; |
|
| 140 | + $admins[$user['username']]['hash'] = sha1($user['username'].$user['password']); |
|
| 141 | 141 | $admins[$user['username']]['profile'] = $user['profile']; |
| 142 | 142 | |
| 143 | - Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', $admins, Cache::JSONGZ, true); |
|
| 144 | - } catch(\Exception $e) { |
|
| 143 | + Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', $admins, Cache::JSONGZ, true); |
|
| 144 | + }catch (\Exception $e) { |
|
| 145 | 145 | Logger::log($e->getMessage(), LOG_ERR); |
| 146 | 146 | $saved = false; |
| 147 | 147 | } |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | public function getAdmins() |
| 180 | 180 | { |
| 181 | - return Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true); |
|
| 181 | + return Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | /** |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | } |
| 207 | 207 | if (!empty($user) && !empty($admins[$user])) { |
| 208 | 208 | $auth = $admins[$user]['hash']; |
| 209 | - $this->authorized = ($auth == sha1($user . $pass)); |
|
| 209 | + $this->authorized = ($auth == sha1($user.$pass)); |
|
| 210 | 210 | if ($this->authorized) { |
| 211 | 211 | $this->admin = array( |
| 212 | 212 | 'alias' => $user, |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | ]); |
| 224 | 224 | $this->setSessionKey(self::LOGGED_USER_TOKEN, base64_encode("{$user}:{$pass}")); |
| 225 | 225 | } |
| 226 | - } else { |
|
| 226 | + }else { |
|
| 227 | 227 | $this->admin = null; |
| 228 | 228 | $this->setSessionKey(self::ADMIN_ID_TOKEN, null); |
| 229 | 229 | } |