From 2ce081e205328e1583bf2a4ef5419ba97e9e46c7 Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Tue, 9 Jul 2024 20:02:04 -0400 Subject: [PATCH] formated result --- www-api/app/Config/Routes.php | 2 +- www-api/app/Controllers/BaseController.php | 2 +- www-api/app/Controllers/WrenchAuth.php | 36 ++++++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/www-api/app/Config/Routes.php b/www-api/app/Config/Routes.php index 3ee53eaa..032a05a4 100644 --- a/www-api/app/Config/Routes.php +++ b/www-api/app/Config/Routes.php @@ -61,7 +61,7 @@ $routes->post('/en/wrench/api/v1/profilepasschange', 'WrenchApi::apigate'); / $routes->post('/en/wrench/api/v1/createmobileuser', 'WrenchApi::apigate'); $routes->post('/en/wrench/api/v1/completemobileuser', 'WrenchApi::apigate'); -$routes->post('/en/wrench/api/v1/startresetpasword', 'WrenchApi::apigate'); +$routes->post('/en/wrench/api/v1/startresetpasword', 'WrenchAuth::passwordReset'); //'WrenchApi::apigate' // $routes->post('/en/wrench/api/v1/userlogin', 'WrenchApi::apigate'); $routes->post('/en/wrench/api/v1/userlogin', 'WrenchAuth::userLogin'); // New routes defined diff --git a/www-api/app/Controllers/BaseController.php b/www-api/app/Controllers/BaseController.php index d7f96e65..34f6e41a 100644 --- a/www-api/app/Controllers/BaseController.php +++ b/www-api/app/Controllers/BaseController.php @@ -471,6 +471,6 @@ abstract class BaseController extends Controller $final_out["family_types"] = $this->familyTypes(); $final_out["history_types"] = $this->historyTypes(); $final_out["refer_link"] = "https://www.wrenchboard.com"; - return json_encode( $final_out ); + return json_encode( $final_out ); } } diff --git a/www-api/app/Controllers/WrenchAuth.php b/www-api/app/Controllers/WrenchAuth.php index fed65fbf..897c8f33 100644 --- a/www-api/app/Controllers/WrenchAuth.php +++ b/www-api/app/Controllers/WrenchAuth.php @@ -50,6 +50,42 @@ class WrenchAuth extends BaseController return $this->respond( $this->summaryReturnData($in,$out), 200); } + + public function passwordReset(){ + + $raw_json = file_get_contents('php://input'); + $in = json_decode($raw_json, true); + $out = []; + + $in["action"] = WRENCHBOARD_RESET_PASSWORD; + $in["rloc"] = 'WRENCHBOARD_RESET_PASSWORD'.rand(1000,9999); + $email_string = $this->restringEmailRedis($in['email']); + $endpoint = "PASS_RESET-". $email_string; + $out_redis = $this->getCache($endpoint); // try find in cache + if (isset($out_redis["password_reset_id"]) && $out_redis["password_reset_id"] > 0){ + // we need stop here + return $this->respond( ["error"=>'Wait and try latter'], 200); + } + + + + $ret = $this->wrenchboard->wrenchboard_api($in, $out); + $out['internal_return'] = $ret; + log_message('critical', "***** ***** WrenchAuth::passwordReset Ret = ".$ret ); + if ( $out['internal_return'] == 100 ){ + log_message('critical', "***** ***** WrenchAuth::userLogin USER_SESSION = ".$endpoint ); + $this->saveCache($endpoint,$out,1500); + } + + return $this->respond( $this->summaryReturnData($in,$out), 200); + + } + + private function restringEmailRedis($str_in){ + $str_out = str_replace("@", "_", $str_in); + return str_replace(".", "_", $str_out); + + } } // WrenchAuth::userLogin \ No newline at end of file