@@ -150,12 +150,11 @@ public function attempt(array $credentials, bool $remember = null): bool
150
150
151
151
$ this ->user = $ this ->validate ($ credentials , true );
152
152
$ 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 ' );
155
154
156
155
// Kalan deneme hakkı hesaplanıyor.
157
156
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 ;
159
158
else $ falseCounter = $ falseLogin ->counter ;
160
159
} else $ falseCounter = null ;
161
160
@@ -381,9 +380,8 @@ public function generateActivateHash()
381
380
/* if return is true user blocked else login active */
382
381
public function isBlockedAttempt ($ username ): bool
383
382
{
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 ) {
387
385
$ whitelist = $ this ->commonModel ->selectOne ('login_rules ' , ['type ' => 'whitelist ' ]);
388
386
if ($ whitelist ) {
389
387
foreach ($ whitelist ->username as $ locked_username )
@@ -415,7 +413,7 @@ public function isBlockedAttempt($username): bool
415
413
if (!$ countLocked ) $ countLockedValue = 0 ;
416
414
else $ countLockedValue = $ countLocked ->counter ;
417
415
418
- if ((int )$ settings ->record <= $ countLockedValue ) {
416
+ if ((int )$ settings ->locked -> record <= $ countLockedValue ) {
419
417
$ this ->commonModel ->edit ('locked ' , ['id ' => $ countLocked ->id ], ['counter ' => 0 ]);
420
418
return false ;
421
419
}
@@ -430,9 +428,9 @@ public function isBlockedAttempt($username): bool
430
428
431
429
$ loginAttempts = $ this ->userModel ->getOneOr ('auth_logins ' , ['isSuccess ' => false ], 'id DESC ' , 'id,counter ' , $ where_or );
432
430
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 ));
436
434
else {
437
435
$ countLockedValue = -1 ;
438
436
$ 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)
500
498
public function remainingEntryCalculation ()
501
499
{
502
500
$ 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 ;
507
504
}
508
505
509
506
public function has_perm (string $ module , string $ method = '' ): bool
@@ -516,6 +513,7 @@ public function has_perm(string $module, string $method = ''): bool
516
513
return $ item ['className ' ] === $ searchValues [0 ] && $ item ['methodName ' ] === $ searchValues [1 ];
517
514
});
518
515
$ perms = reset ($ perms );
516
+ //dd($perms['typeOfPermissions']);
519
517
$ typeOfPermissions = (array )json_decode ($ perms ['typeOfPermissions ' ]);
520
518
$ intersect = array_intersect_assoc ($ typeOfPermissions , $ perms );
521
519
if (!empty ($ intersect )) return true ;
0 commit comments