FIX_UPDATE_MPIN : RV
This commit is contained in:
parent
4b64bbb088
commit
903f8c93ea
@ -180,26 +180,43 @@ class RestAuthenticationController extends AdminController
|
||||
|
||||
public function updateEmpMPIN()
|
||||
{
|
||||
|
||||
$mobile_number = isset($this->request->getJSON()->mobile_number) ? $this->request->getJSON()->mobile_number : null;
|
||||
$email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null;
|
||||
|
||||
if (isset($mobile_number)) {
|
||||
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
|
||||
$requestData = $this->request->getJSON();
|
||||
$mobile_number = $requestData->mobile_number ?? null;
|
||||
$email_id = $requestData->email_id ?? null;
|
||||
$new_mpin = $requestData->new_mpin ?? $requestData->mpin ?? null;
|
||||
$old_mpin = $requestData->old_mpin ?? null;
|
||||
|
||||
if (!$new_mpin) {
|
||||
return $this->response->setJSON(['status' => false, 'message' => 'MPIN is required.']);
|
||||
}
|
||||
|
||||
$query = $this->employeeModel->where('relationship', 'self');
|
||||
|
||||
if ($mobile_number) {
|
||||
$query->where('mobile', $mobile_number);
|
||||
} elseif ($email_id) {
|
||||
$query->where('email_corporate', $email_id);
|
||||
} else {
|
||||
$employeeData = $this->employeeModel->where('email_corporate', $email_id)->where('relationship', 'self')->first();
|
||||
return $this->response->setJSON(['status' => false, 'message' => 'Mobile number or Email ID is required.']);
|
||||
}
|
||||
|
||||
$mpin = $this->request->getJSON()->mpin;
|
||||
|
||||
if ($employeeData) {
|
||||
$id= $employeeData["id"];
|
||||
$updateMpin = $this->employeeModel->where('id', $id)->set('mpin', $mpin)->update();
|
||||
|
||||
if (!empty($old_mpin)) {
|
||||
$query->where('mpin', $old_mpin);
|
||||
}
|
||||
|
||||
|
||||
// Fetch employee data
|
||||
$employeeData = $query->first();
|
||||
|
||||
if (!$employeeData) {
|
||||
return $this->response->setJSON(['status' => false, 'message' => 'Employee not found or invalid MPIN.']);
|
||||
}
|
||||
|
||||
// Update MPIN
|
||||
$updated = $this->employeeModel->update($employeeData['id'], ['mpin' => $new_mpin]);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getVerifiedUserData()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user