CHANGES_in rest login api in employee login : GWM
This commit is contained in:
parent
6bf965fea9
commit
7bade8ce01
@ -286,9 +286,9 @@ $routes->group("/api", ["filter" => "authJWT"], function ($routes) {
|
||||
|
||||
|
||||
|
||||
$routes->get("getEmployeeActiveOrInactivePolicy", "EmployeeRestController::getEmployeeActiveOrInactivePolicy");
|
||||
|
||||
$routes->get("getChatResponse", "ChatBotController::getChatResponse");
|
||||
|
||||
|
||||
$routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {
|
||||
$routes->post("storeFireBase", "EmployeeRestController::storeFireBase");
|
||||
$routes->post("saveMpin", "RestAuthenticationController::saveMpin");
|
||||
|
||||
@ -69,15 +69,13 @@ class RestAuthenticationController extends AdminController
|
||||
{
|
||||
try {
|
||||
$mobile_number = $this->request->getJSON()->mobile_number;
|
||||
$randomNumber = rand(100000, 999999);
|
||||
$randomNumber = 123456;
|
||||
|
||||
|
||||
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
|
||||
|
||||
if ($employeeData) {
|
||||
$id= $employeeData["id"];
|
||||
$otp = $this->employeeModel->where('id', $id)->set('otp', $randomNumber)->update();
|
||||
$result = ['user_verification' => true ,'message' => "Verified Successfully", 'otp'=>$randomNumber];
|
||||
|
||||
$result = ['user_verification' => true ,'message' => "Verified Successfully"];
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
|
||||
} else {
|
||||
$result = ['user_verification' => false , 'message' => "User not found"];
|
||||
@ -92,13 +90,13 @@ class RestAuthenticationController extends AdminController
|
||||
|
||||
public function getVerifiedUserData()
|
||||
{
|
||||
// try {
|
||||
try {
|
||||
$mobile_number = $this->request->getJSON()->mobile_number;
|
||||
$otp = $this->request->getJSON()->otp;
|
||||
$otp_verification = $this->request->getJSON()->otp_verification;
|
||||
|
||||
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
|
||||
|
||||
if ($employeeData && $otp == $employeeData["otp"] || $employeeData && isset($this->request->getJSON()->login_by_hr)) {
|
||||
if ($employeeData && $otp_verification == true || $employeeData && isset($this->request->getJSON()->login_by_hr)) {
|
||||
$auth = HttpRequestHelper::getRequestInfo();
|
||||
if ($auth) {
|
||||
$data = [
|
||||
@ -108,22 +106,19 @@ class RestAuthenticationController extends AdminController
|
||||
'platform' => $auth['platform'],
|
||||
'broswer' => $auth['browser'],
|
||||
];
|
||||
|
||||
$authdata= $this->authHistoryModel->insert($data);
|
||||
|
||||
$this->authHistoryModel->insert($data);
|
||||
}
|
||||
$otp_null = $this->employeeModel->where('id', $employeeData["id"])->set('otp', null)->update();
|
||||
|
||||
|
||||
|
||||
|
||||
$result = JWTToken::encode($employeeData);
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
|
||||
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);
|
||||
// }
|
||||
} catch (\Exception $e) {
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()],500);
|
||||
}
|
||||
}
|
||||
|
||||
public function verifyHrWithMobileNumber()
|
||||
@ -190,11 +185,6 @@ class RestAuthenticationController extends AdminController
|
||||
|
||||
|
||||
|
||||
public function employeeLogout()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function getUserIdFromToken()
|
||||
{
|
||||
$id = JWTToken::getUserIdFromToken();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user