From 23e676e5bcde7e0f01a2c7bf58882918e7ed6004 Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Sun, 7 Jul 2024 18:28:51 -0400 Subject: [PATCH] Improved session monitoring --- www-api/app/Controllers/BaseController.php | 4 +++- www-api/app/Controllers/WrenchAccount.php | 21 ++++++++++++++++++--- www-api/app/Controllers/WrenchAuth.php | 22 ++++++++++++++++++---- 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/www-api/app/Controllers/BaseController.php b/www-api/app/Controllers/BaseController.php index 46e7e44c..0f7c8853 100644 --- a/www-api/app/Controllers/BaseController.php +++ b/www-api/app/Controllers/BaseController.php @@ -1,13 +1,15 @@ string 'OluNG' (length=5) + 'lastname' => string 'AmeyNG' (length=6) + 'email' => string 'ameye+auglonger3646@chiefsoft.com' (length=33) + 'username' => string 'ameye+auglonger3646@chiefsoft.com' (length=33) + 'password' => string 'may12002' (length=8) + 'terms' => int 1 + 'news' => int 1 + 'loc' => string '38.101.241.200' (length=14) + 'country' => string 'NG' (length=2) + 'action' => int 11010 + */ $out=[]; $raw_json = file_get_contents('php://input'); @@ -27,7 +40,9 @@ class WrenchAccount extends BaseController $ret = $this->wrenchboard->wrenchboard_api($in, $out); $out['internal_return'] = $ret; - return $this->summaryReturnData($in,$out); //json_encode( $final_out ); + return $this->respond( $this->summaryReturnData($in,$out), 200); + + // return $this->summaryReturnData($in,$out); //json_encode( $final_out ); } } \ No newline at end of file diff --git a/www-api/app/Controllers/WrenchAuth.php b/www-api/app/Controllers/WrenchAuth.php index 82e862c5..308449e3 100644 --- a/www-api/app/Controllers/WrenchAuth.php +++ b/www-api/app/Controllers/WrenchAuth.php @@ -2,8 +2,11 @@ namespace App\Controllers; +use CodeIgniter\API\ResponseTrait; + class WrenchAuth extends BaseController { + use ResponseTrait; public function userLogin(){ // $in = $this->request->getPostGet(); @@ -14,15 +17,26 @@ class WrenchAuth extends BaseController if (!isset($in["login_mode"])){ $in["login_mode"] = MOBILE_LOGIN; } - $endpoint = "USER_SESSION-"; + $out=[]; // $out = $this->getCache($endpoint); // try find in cache - // if ( empty($out) || !is_array($out)){ $ret = $this->wrenchboard->wrenchboard_api($in, $out); $out['internal_return'] = $ret; - $this->saveCache($endpoint,$out,15000); + if ( $out['internal_return'] == 100 ){ + $endpoint = "USER_SESSION-"; + $this->saveCache($endpoint,$out,15000); + }else + { + $outF["username"] = $in["username"]; + $outF["loc"] = $in["loc"]; + $endpoint = "LOGIN_FAILED-".$outF["username"]."-"; + $this->saveCache($endpoint,$outF,15000); + } // } - return $this->summaryReturnData($in,$out); //json_encode( $final_out ); + + return $this->respond( $this->summaryReturnData($in,$out), 200); + + // return $this->summaryReturnData($in,$out); //json_encode( $final_out ); } }