From 15f080e1df91edebcbc3bfe952ee220cab3398ad Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Tue, 1 Apr 2025 09:39:28 +0530 Subject: [PATCH] FIX_VRIFY_MPIN : RV --- .../RestAuthenticationController.php | 41 +++++++++---------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/app/Controllers/RestAuthenticationController.php b/app/Controllers/RestAuthenticationController.php index 577f0b9..66489ee 100755 --- a/app/Controllers/RestAuthenticationController.php +++ b/app/Controllers/RestAuthenticationController.php @@ -413,47 +413,44 @@ class RestAuthenticationController extends AdminController $email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null; $mpin = $this->request->getJSON()->mpin; - if (isset($mobile_number)) - { + if (isset($mobile_number)) { $employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first(); - }else{ + } else { $employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('relationship', 'self')->first(); } - + if ($employeeData && $mpin == $employeeData["mpin"]) { $auth = HttpRequestHelper::getRequestInfo(); if ($auth) { $data = [ - 'user_id' => $employeeData['id'], - 'user_type' => 'employee', - 'ip' => $auth['ip'], - 'platform' => $auth['platform'], - 'broswer' => $auth['browser'], + 'user_id' => $employeeData['id'], + 'user_type' => 'employee', + 'ip' => $auth['ip'], + 'platform' => $auth['platform'], + 'broswer' => $auth['browser'], ]; - $authdata= $this->authHistoryModel->insert($data); - + $authdata = $this->authHistoryModel->insert($data); } $result = JWTToken::encode($employeeData); // Call the third-party API function - $apiResponse = $this->callThirdPartyAPI($this->request->getJSON(),'verifyMpin'); - return $this->respond(['status' => 'success','code' => 200,'data' => $result , 'post_enrollment'=> json_decode($apiResponse, true)],200); + $apiResponse = $this->callThirdPartyAPI($this->request->getJSON(), 'verifyMpin'); + return $this->respond(['status' => 'success', 'code' => 200, 'data' => $result, 'post_enrollment' => json_decode($apiResponse, true)], 200); } else { // Call the third-party API function - - $apiResponse = $this->callThirdPartyAPI($this->request->getJSON(),'/employeeRest/verifyMpin'); - - return $this->respond(['status' => 'success','code' => 200 , 'post_enrollment'=> json_decode($apiResponse, true)],200); - + + $apiResponse = $this->callThirdPartyAPI($this->request->getJSON(), '/employeeRest/verifyMpin'); + return $this->respond(['status' => 'failed', 'code' => 404, 'data' => "Invalid OTP", 'post_enrollment' => json_decode($apiResponse, true)], 200); + //$apiResponse = $this->callThirdPartyAPI($this->request->getJSON(),'/getVerifiedUserData'); - // return $this->respond(['status' => 'failed','code' => 404,'data' => "Invalid OTP", 'post_enrollment'=> json_decode($apiResponse, true)],200); - - } + + } } catch (\Exception $e) { - return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()],500); + return $this->respond(['status' => 'failed', 'code' => 500, 'data' => $e->getMessage()], 500); + return $this->respond(['status' => 'failed', 'code' => 200, 'post_enrollment' => json_decode($apiResponse, true)], 200); } }