Skip to content

Commit c1a1fe4

Browse files
bugs fixed.
1 parent 69883f3 commit c1a1fe4

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

app/Controllers/BaseController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,6 @@ public function initController(RequestInterface $request, ResponseInterface $res
6666
// E.g.: $this->session = \Config\Services::session();
6767
$this->commonModel = new CommonModel();
6868
$this->ci4msseoLibrary = new Ci4msseoLibrary();
69-
$this->defData = ['settings' => (object)cache('settings'), 'menus' => $this->commonModel->lists('menu', '*', [], 'queue ASC')];
69+
$this->defData = ['settings' => (object)cache('settings'), 'menus' => $this->commonModel->lists('menu', '*', [], 'queue ASC'), 'agent'=>$this->request->getUserAgent()];
7070
}
7171
}

modules/Backend/Controllers/Settings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public function templateSelectPost()
205205
if ($this->commonModel->edit('settings',
206206
['content' => json_encode(['path' => $this->request->getPost('path'),
207207
'name' => $this->request->getPost('name')], JSON_UNESCAPED_UNICODE)],
208-
['opiton' => 'templateInfos'])) {
208+
['option' => 'templateInfos'])) {
209209
cache()->delete('settings');
210210
return $this->response->setJSON(['result' => true]);
211211
} else return $this->response->setJSON(['result' => false]);

modules/Backend/Libraries/AuthLibrary.php

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,11 @@ public function attempt(array $credentials, bool $remember = null): bool
150150

151151
$this->user = $this->validate($credentials, true);
152152
$falseLogin = $this->commonModel->selectOne('auth_logins', ['ip_address' => $this->ipAddress], '*', 'id DESC');
153-
$settings=cache('settings');
154-
$settings = (object)json_decode(array_reduce($settings, fn($carry, $item) => $carry ?? ('locked' == $item->option ? $item : null))->content, true);
153+
$settings=(object)cache('settings');
155154

156155
// Kalan deneme hakkı hesaplanıyor.
157156
if ($falseLogin && $falseLogin->isSuccess === false) {
158-
if ($falseLogin->counter && ((int)$falseLogin->counter + 1) >= (int)$settings->try) $falseCounter = -1;
157+
if ($falseLogin->counter && ((int)$falseLogin->counter + 1) >= (int)$settings->locked->try) $falseCounter = -1;
159158
else $falseCounter = $falseLogin->counter;
160159
} else $falseCounter = null;
161160

@@ -381,9 +380,8 @@ public function generateActivateHash()
381380
/* if return is true user blocked else login active */
382381
public function isBlockedAttempt($username): bool
383382
{
384-
$settings=cache('settings');
385-
$settings = (object)json_decode(array_reduce($settings, fn($carry, $item) => $carry ?? ('locked' == $item->option ? $item : null))->content, true);
386-
if ($settings->isActive) {
383+
$settings=(object)cache('settings');
384+
if ($settings->locked->isActive) {
387385
$whitelist = $this->commonModel->selectOne('login_rules', ['type' => 'whitelist']);
388386
if ($whitelist) {
389387
foreach ($whitelist->username as $locked_username)
@@ -415,7 +413,7 @@ public function isBlockedAttempt($username): bool
415413
if (!$countLocked) $countLockedValue = 0;
416414
else $countLockedValue = $countLocked->counter;
417415

418-
if ((int)$settings->record <= $countLockedValue) {
416+
if ((int)$settings->locked->record <= $countLockedValue) {
419417
$this->commonModel->edit('locked', ['id' => $countLocked->id], ['counter' => 0]);
420418
return false;
421419
}
@@ -430,9 +428,9 @@ public function isBlockedAttempt($username): bool
430428

431429
$loginAttempts = $this->userModel->getOneOr('auth_logins', ['isSuccess' => false], 'id DESC', 'id,counter', $where_or);
432430

433-
if ($loginAttempts && isset($loginAttempts->counter) && ($loginAttempts->counter + 1) >= (int)$settings->try) {
434-
if (($countLockedValue + 1) < ((int)$settings->record))
435-
$expiry_date = Time::createFromFormat('Y-m-d H:i:s', $this->now->addMinutes((int)$settings->min));
431+
if ($loginAttempts && isset($loginAttempts->counter) && ($loginAttempts->counter + 1) >= (int)$settings->locked->try) {
432+
if (($countLockedValue + 1) < ((int)$settings->locked->record))
433+
$expiry_date = Time::createFromFormat('Y-m-d H:i:s', $this->now->addMinutes((int)$settings->locked->min));
436434
else {
437435
$countLockedValue = -1;
438436
$expiry_date = Time::createFromFormat('Y-m-d H:i:s', $this->now->addMinutes(1440)); // 24 hours ago
@@ -500,10 +498,9 @@ public function ip2long_vX($ip)
500498
public function remainingEntryCalculation()
501499
{
502500
$falseLogin = $this->commonModel->selectOne('auth_logins', ['ip_address' => $this->ipAddress], '*', 'id DESC');
503-
$settings=cache('settings');
504-
$settings = (object)json_decode(array_reduce($settings, fn($carry, $item) => $carry ?? ('locked' == $item->option ? $item : null))->content, true);
505-
if ($falseLogin) return (int)$settings->try - (int)$falseLogin->counter - 1;
506-
else return (int)$settings->try - 1;
501+
$settings=(object)cache('settings');
502+
if ($falseLogin) return (int)$settings->locked->try - (int)$falseLogin->counter - 1;
503+
else return (int)$settings->locked->try - 1;
507504
}
508505

509506
public function has_perm(string $module, string $method = ''): bool
@@ -516,6 +513,7 @@ public function has_perm(string $module, string $method = ''): bool
516513
return $item['className'] === $searchValues[0] && $item['methodName'] === $searchValues[1];
517514
});
518515
$perms = reset($perms);
516+
//dd($perms['typeOfPermissions']);
519517
$typeOfPermissions = (array)json_decode($perms['typeOfPermissions']);
520518
$intersect = array_intersect_assoc($typeOfPermissions, $perms);
521519
if(!empty($intersect)) return true;

0 commit comments

Comments
 (0)