CHANGE_ mpin : GWM
This commit is contained in:
parent
8f57f3e8b1
commit
8a36f96d05
@ -271,6 +271,7 @@ $routes->get("processjob", "JobWorker::processJob");
|
||||
//Employee login api's
|
||||
$routes->post("/employeeRest/verifyEmployeeNumber", "RestAuthenticationController::verifyEmployeeWithMobileNumber");
|
||||
$routes->post("/employeeRest/getVerifiedUserData", "RestAuthenticationController::getVerifiedUserData");
|
||||
$routes->post("/employeeRest/verifyMpin", "RestAuthenticationController::verifyMpin");
|
||||
//HR login api's
|
||||
$routes->post("/employeeRest/verifyHrWithMobileNumber", "RestAuthenticationController::verifyHrWithMobileNumber");
|
||||
$routes->post("/employeeRest/getVerifiedHrData", "RestAuthenticationController::getVerifiedHrData");
|
||||
@ -282,10 +283,11 @@ $routes->group("/api", ["filter" => "authJWT"], function ($routes) {
|
||||
|
||||
|
||||
|
||||
$routes->get("getEmployeePolicy", "EmployeeRestController::getEmployeePolicy");
|
||||
$routes->get("getAddOnPolicy", "EmployeeRestController::getAddOnPolicy");
|
||||
|
||||
$routes->get("getChatResponse", "ChatBotController::getChatResponse");
|
||||
$routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
|
||||
$routes->post("saveMpin", "RestAuthenticationController::saveMpin");
|
||||
$routes->post("updateMpin", "RestAuthenticationController::updateMpin");
|
||||
$routes->get("getChatResponse", "ChatBotController::getChatResponse");
|
||||
$routes->get("getEmployeeProfile", "EmployeeRestController::getEmployeeProfile");
|
||||
$routes->post("employeeUpload", "EmployeeRestController::employeeUpload");
|
||||
|
||||
@ -212,5 +212,104 @@ class RestAuthenticationController extends AdminController
|
||||
}
|
||||
|
||||
|
||||
public function saveMpin()
|
||||
{
|
||||
try {
|
||||
$mobile_number = $this->request->getJSON()->mobile_number;
|
||||
$mpin = $this->request->getJSON()->mpin;
|
||||
|
||||
|
||||
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
|
||||
|
||||
if ($employeeData) {
|
||||
$id= $employeeData["id"];
|
||||
$updateMpin = $this->employeeModel->where('id', $id)->set('mpin', $mpin)->update();
|
||||
if($updateMpin){
|
||||
$result = ['user_verification' => true , 'message' => "Mpin Updated"];
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
|
||||
}else{
|
||||
$result = ['user_verification' => true , 'message' => "Mpin Not Updated"];
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => $result],200);
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
$result = ['user_verification' => false , 'message' => "User not found"];
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => $result],200);
|
||||
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
|
||||
}
|
||||
}
|
||||
|
||||
public function updateMpin()
|
||||
{
|
||||
try {
|
||||
$mobile_number = $this->request->getJSON()->mobile_number;
|
||||
$old_mpin = $this->request->getJSON()->old_mpin;
|
||||
$mpin = $this->request->getJSON()->new_mpin;
|
||||
|
||||
|
||||
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('mpin', $old_mpin)->where('relationship', 'self')->first();
|
||||
|
||||
if ($employeeData) {
|
||||
$id= $employeeData["id"];
|
||||
$updateMpin = $this->employeeModel->where('id', $id)->set('mpin', $mpin)->update();
|
||||
if($updateMpin){
|
||||
$result = ['mpin_verification' => true , 'message' => "Mpin Updated"];
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
|
||||
}else{
|
||||
$result = ['mpin_verification' => true , 'message' => "Mpin Not Updated"];
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => $result],200);
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
$result = ['mpin_verification' => false , 'message' => "Wrong Mpin"];
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => $result],200);
|
||||
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
|
||||
}
|
||||
}
|
||||
|
||||
public function verifyMpin()
|
||||
{
|
||||
try {
|
||||
$mobile_number = $this->request->getJSON()->mobile_number;
|
||||
$mpin = $this->request->getJSON()->mpin;
|
||||
|
||||
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->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'],
|
||||
];
|
||||
|
||||
$authdata= $this->authHistoryModel->insert($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$result = JWTToken::encode($employeeData);
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
|
||||
} else {
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => "Invalid OTP"],200);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()],500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -40,7 +40,8 @@ class EmployeeModel extends Model
|
||||
"is_createdby_hr",
|
||||
"client_branch_id",
|
||||
"token_time_out",
|
||||
"emp_type"
|
||||
"emp_type",
|
||||
"mpin"
|
||||
];
|
||||
|
||||
// Callbacks
|
||||
|
||||
Loading…
Reference in New Issue
Block a user