From b8f237dfe5c68e9f17cda7ef5483073fb6f6447e Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Sun, 7 Jul 2024 19:12:49 -0400 Subject: [PATCH] fix login --- www-api/app/Controllers/WrenchAuth.php | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/www-api/app/Controllers/WrenchAuth.php b/www-api/app/Controllers/WrenchAuth.php index c9b09612..01575d35 100644 --- a/www-api/app/Controllers/WrenchAuth.php +++ b/www-api/app/Controllers/WrenchAuth.php @@ -18,8 +18,20 @@ class WrenchAuth extends BaseController $in["login_mode"] = MOBILE_LOGIN; } + + // make safe for redis + $outF["username"] = str_replace("@", "_", $in["username"]); + $outF["username"] = str_replace(".", "_", $outF["username"]); + $outF["original_username"] = $in["username"]; + $outF["loc"] = $in["loc"]; + $fail_endpoint = "LOGIN_FAILED-".$outF["username"]."-"; + //===================REDIS DATA IN CASE OF FAIL + $out_redis = $this->getCache($fail_endpoint); // try find in cache + if ( isset($out_redis) && isset($out_redis["fail_count"]) && $out_redis["fail_count"] > 2 ){ + // we need stop here + } $out=[]; - // $out = $this->getCache($endpoint); // try find in cache + $ret = $this->wrenchboard->wrenchboard_api($in, $out); $out['internal_return'] = $ret; log_message('critical', "***** ***** WrenchAuth::userLogin Ret = ".$ret ); @@ -29,14 +41,9 @@ class WrenchAuth extends BaseController $this->saveCache($endpoint,$out,15000); }else { - // make safe for redis - $outF["username"] = str_replace("@", "_", $in["username"]); - $outF["username"] = str_replace(".", "_", $outF["username"]); - - $outF["loc"] = $in["loc"]; - $endpoint = "LOGIN_FAILED-".$outF["username"]."-"; - log_message('critical', "***** ***** WrenchAuth::userLogin USER_SESSION = ".$endpoint ); - $this->saveCache($endpoint,$outF,15000); + $outF["fail_count"] = isset( $out_redis["fail_count"] ) ? $out_redis["fail_count"]+1:1; + log_message('critical', "***** ***** WrenchAuth::userLogin USER_SESSION = ".$fail_endpoint ); + $this->saveCache($fail_endpoint,$outF,15000); } // }