@@ -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 | } |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | */ |
191 | 191 | public function getAdmins() |
192 | 192 | { |
193 | - return Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true); |
|
193 | + return Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
@@ -218,9 +218,9 @@ discard block |
||
218 | 218 | } |
219 | 219 | if (!empty($user) && !empty($admins[$user])) { |
220 | 220 | $auth = $admins[$user]['hash']; |
221 | - $this->authorized = ($auth == sha1($user . $pass)); |
|
221 | + $this->authorized = ($auth == sha1($user.$pass)); |
|
222 | 222 | if ($this->authorized) { |
223 | - $this->updateAdmin($user , $admins[$user]['profile']); |
|
223 | + $this->updateAdmin($user, $admins[$user]['profile']); |
|
224 | 224 | ResponseHelper::setCookieHeaders([ |
225 | 225 | [ |
226 | 226 | 'name' => $this->getHash(), |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | ]); |
232 | 232 | $this->setSessionKey(self::LOGGED_USER_TOKEN, base64_encode("{$user}:{$pass}")); |
233 | 233 | } |
234 | - } else { |
|
234 | + }else { |
|
235 | 235 | $this->admin = null; |
236 | 236 | $this->setSessionKey(self::ADMIN_ID_TOKEN, null); |
237 | 237 | } |