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