CHANGE_MPIN : RV
This commit is contained in:
parent
ef057590c9
commit
b7c701f35a
@ -445,6 +445,7 @@ $routes->group("/api", ["filter" => "authJWT"], function ($routes) {
|
||||
|
||||
$routes->post("employeeRest/saveMpin", "RestAuthenticationController::saveMpin");
|
||||
$routes->post("employeeRest/updateMpin", "RestAuthenticationController::updateMpin");
|
||||
$routes->post("employeeRest/forgotMPIN", "RestAuthenticationController::forgotMPIN");
|
||||
$routes->post("calculatePremium", "EmployeeRestController::calculatePremium");
|
||||
|
||||
// $routes->post("employeeRest/createOrUpdateEmployeePolicySiAmount", "EmployeeRestController::createOrUpdateEmployeePolicySiAmount");
|
||||
|
||||
@ -492,13 +492,18 @@ class RestAuthenticationController extends AdminController
|
||||
}
|
||||
|
||||
$mpin = $this->request->getJSON()->mpin;
|
||||
$is_mpin_skipped = $this->request->getJSON()->is_mpin_skipped;
|
||||
$is_biometric_enabled = $this->request->getJSON()->is_biometric_enabled;
|
||||
|
||||
|
||||
|
||||
$mpin_data_to_updata = [
|
||||
'mpin' => $mpin,
|
||||
'is_mpin_skipped' => $is_mpin_skipped,
|
||||
'is_biometric_enabled' => $is_biometric_enabled
|
||||
];
|
||||
|
||||
if ($employeeData) {
|
||||
$id= $employeeData["id"];
|
||||
$updateMpin = $this->employeeModel->where('id', $id)->set('mpin', $mpin)->update();
|
||||
$updateMpin = $this->employeeModel->where('id', $id)->set($mpin_data_to_updata)->update();
|
||||
if($updateMpin){
|
||||
$this->callThirdPartyAPI($this->request->getJSON(), 'updateEmpMPIN');
|
||||
$result = ['user_verification' => true , 'message' => "Mpin Updated"];
|
||||
@ -623,7 +628,7 @@ class RestAuthenticationController extends AdminController
|
||||
|
||||
if ($employeeData && $employeeData["mpin"] != null) {
|
||||
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => "Mpin - exist" , 'Mpin' =>$employeeData["mpin"]],200);
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => "Mpin - exist" , 'Mpin' =>$employeeData["mpin"], 'is_mpin_skipped' => $employeeData['is_mpin_skipped'], 'is_biometric_enabled' => $employeeData['is_biometric_enabled']],200);
|
||||
} else {
|
||||
// return $this->respond(['status' => 'failed','code' => 404,'data' => "Mpin - not found", 'Mpin' =>null],200);
|
||||
return $this->callThirdPartyAPI($this->request->getJSON(), 'checkMpin');
|
||||
@ -634,6 +639,86 @@ class RestAuthenticationController extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
public function forgotMPIN()
|
||||
{
|
||||
try {
|
||||
log_message('info', 'forgotMPIN() called.');
|
||||
|
||||
$json = $this->request->getJSON();
|
||||
$mobile_number = $json->mobile_number ?? null;
|
||||
$email_id = $json->email_id ?? null;
|
||||
|
||||
log_message('info', 'Received input - Mobile: ' . var_export($mobile_number, true) . ', Email: ' . var_export($email_id, true));
|
||||
|
||||
// Step 1: Check input
|
||||
if (!$mobile_number && !$email_id) {
|
||||
log_message('error', 'Mobile number and email ID are both missing.');
|
||||
return $this->respond([
|
||||
'status' => 'failed',
|
||||
'code' => 400,
|
||||
'message' => 'Mobile number or email ID is required.'
|
||||
], 400);
|
||||
}
|
||||
|
||||
// Step 2: Fetch employee data
|
||||
if ($mobile_number) {
|
||||
log_message('info', 'Looking up employee by mobile number: ' . $mobile_number);
|
||||
$employeeData = $this->employeeModel
|
||||
->where('mobile', $mobile_number)
|
||||
->where('relationship', 'self')
|
||||
->first();
|
||||
} else {
|
||||
log_message('info', 'Looking up employee by email: ' . $email_id);
|
||||
$employeeData = $this->employeeModel
|
||||
->where('email_corporate', $email_id)
|
||||
->where('relationship', 'self')
|
||||
->first();
|
||||
}
|
||||
|
||||
// Step 3: Found employee
|
||||
if (!empty($employeeData)) {
|
||||
log_message('info', 'Employee found: ID = ' . $employeeData['id']);
|
||||
|
||||
$updateData = [
|
||||
'mpin' => null,
|
||||
'is_mpin_skipped' => null,
|
||||
'is_biometric_enabled' => null
|
||||
];
|
||||
|
||||
log_message('info', 'Updating employee MPIN fields to null for ID: ' . $employeeData['id']);
|
||||
|
||||
$updated = $this->employeeModel
|
||||
->where('id', $employeeData['id'])
|
||||
->set($updateData)
|
||||
->update();
|
||||
|
||||
if ($updated) {
|
||||
log_message('info', 'MPIN reset successful for employee ID: ' . $employeeData['id']);
|
||||
return $this->respond([
|
||||
'status' => 'success',
|
||||
'code' => 200,
|
||||
'message' => 'MPIN reset successfully.'
|
||||
], 200);
|
||||
} else {
|
||||
log_message('error', 'Failed to update MPIN fields for employee ID: ' . $employeeData['id']);
|
||||
return $this->respond([
|
||||
'status' => 'failed',
|
||||
'code' => 500,
|
||||
'message' => 'Could not reset MPIN values.',
|
||||
], 500);
|
||||
}
|
||||
} else {
|
||||
// Step 4: Not found in local DB — call external fallback
|
||||
log_message('warning', 'Employee not found locally. Falling back to third-party API.');
|
||||
return $this->callThirdPartyAPI($json, 'forgotMPIN');
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
log_message('error', 'Exception in forgotMPIN(): ' . $e->getMessage());
|
||||
return $this->respond([
|
||||
'status' => 'failed',
|
||||
'code' => 500,
|
||||
'message' => 'Server error: ' . $e->getMessage()
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -42,7 +42,9 @@ class EmployeeModel extends Model
|
||||
"token_time_out",
|
||||
"emp_type",
|
||||
"unit",
|
||||
"mpin"
|
||||
"mpin",
|
||||
"is_mpin_skipped",
|
||||
"is_biometric_enabled",
|
||||
];
|
||||
|
||||
// Callbacks
|
||||
|
||||
@ -160,7 +160,7 @@
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<!--
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label>Contact 1</label>
|
||||
@ -179,11 +179,12 @@
|
||||
name="designation[]" id="designation" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="last_name">Email<span class="text-danger">*</span></label>
|
||||
<input value="" type="text" class="form-control" placeholder="Enter Contact Email"
|
||||
name="email[]" id="email" data-parsley-trigger="change" data-parsley-type="email" required>
|
||||
name="email[]" id="email" data-parsley-trigger="change" data-parsley-type="email" onchange="validateInput(this, 'level_contacts', 'email')" required>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="mobile">Mobile<span class="text-danger">*</span></label>
|
||||
@ -195,6 +196,7 @@
|
||||
required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group" style="display: flex;">
|
||||
<button style="margin-right: 10px;" type="button" class="btn btn-primary btn-sm ac"
|
||||
onclick="appendContactHtml()" id="add">Add Contact</button>
|
||||
@ -202,7 +204,7 @@
|
||||
id="remove_btn">Remove</button>
|
||||
</div>
|
||||
|
||||
<div id="container"></div> -->
|
||||
<div id="container"></div>
|
||||
|
||||
</div>
|
||||
<div class="form-group text-right m-b-0">
|
||||
@ -596,7 +598,7 @@ function appendContactHtml(contact = false, reset = false) {
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="${uniqueId}_last_name">Email<span class="text-danger">*</span></label>
|
||||
<input value="${contact !== undefined && contact !== false ? contact.email : ''}" type="text" class="form-control" placeholder="Enter Contact Email" name="email[]" id="${uniqueId}_email" data-parsley-trigger="change" data-parsley-type="email" required>
|
||||
<input value="${contact !== undefined && contact !== false ? contact.email : ''}" type="text" class="form-control" placeholder="Enter Contact Email" name="email[]" id="${uniqueId}_email" data-parsley-trigger="change" data-parsley-type="email" onchange="validateInput(this, 'level_contacts', 'email')" required>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="${uniqueId}_mobile">Mobile<span class="text-danger">*</span></label>
|
||||
@ -772,6 +774,25 @@ function checkMobileNumber(input) {
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function validateInput(input, table, field){
|
||||
|
||||
let value = $(input).val();
|
||||
let label = $(input).closest('.form-group').find('label').text().replace('*', '').trim();
|
||||
|
||||
let message = "Value is duplicate!";
|
||||
if(label){
|
||||
message = label + " already exists!";
|
||||
}
|
||||
|
||||
checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) {
|
||||
if (isDuplicate) {
|
||||
toastr.warning(message, 'WARNING');
|
||||
$(input).val('')
|
||||
}
|
||||
});
|
||||
|
||||
}s
|
||||
</script>
|
||||
|
||||
<script>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user