FIX_UPDATE_MPIN : RV
This commit is contained in:
parent
4b64bbb088
commit
903f8c93ea
@ -180,28 +180,45 @@ class RestAuthenticationController extends AdminController
|
|||||||
|
|
||||||
public function updateEmpMPIN()
|
public function updateEmpMPIN()
|
||||||
{
|
{
|
||||||
|
$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;
|
||||||
|
|
||||||
$mobile_number = isset($this->request->getJSON()->mobile_number) ? $this->request->getJSON()->mobile_number : null;
|
if (!$new_mpin) {
|
||||||
$email_id = isset($this->request->getJSON()->email_id) ? $this->request->getJSON()->email_id : null;
|
return $this->response->setJSON(['status' => false, 'message' => 'MPIN is required.']);
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($mobile_number)) {
|
$query = $this->employeeModel->where('relationship', 'self');
|
||||||
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
|
|
||||||
|
if ($mobile_number) {
|
||||||
|
$query->where('mobile', $mobile_number);
|
||||||
|
} elseif ($email_id) {
|
||||||
|
$query->where('email_corporate', $email_id);
|
||||||
} else {
|
} 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 (!empty($old_mpin)) {
|
||||||
|
$query->where('mpin', $old_mpin);
|
||||||
if ($employeeData) {
|
|
||||||
$id= $employeeData["id"];
|
|
||||||
$updateMpin = $this->employeeModel->where('id', $id)->set('mpin', $mpin)->update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function getVerifiedUserData()
|
public function getVerifiedUserData()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user