FEAT_POS_LOGIN_FIREBASE_AND_LIVE_ISSUE : RV
This commit is contained in:
parent
c10e109a05
commit
19e4e36076
@ -46,6 +46,9 @@ $routes->get("frontend_content", "AppContentManagementController::frontend_conte
|
|||||||
// $routes->get('/', 'LoginController::index');
|
// $routes->get('/', 'LoginController::index');
|
||||||
$routes->get('/test', 'Home::index');
|
$routes->get('/test', 'Home::index');
|
||||||
$routes->get('/login', 'LoginController::index'); ///auth/google
|
$routes->get('/login', 'LoginController::index'); ///auth/google
|
||||||
|
$routes->get('/loginPos', 'LoginController::loginPos'); //login POS team
|
||||||
|
$routes->post('/getVerifyPosMobileNo', 'LoginController::getVerifyPosMobileNo'); //Verify POS team mobile no
|
||||||
|
$routes->post('/getVerifiedPosUserData', 'LoginController::getVerifiedPosUserData'); //Verify POS team user data
|
||||||
$routes->get('/logout', 'LoginController::logout');
|
$routes->get('/logout', 'LoginController::logout');
|
||||||
$routes->get('/oauth2callback', 'LoginController::receiveGoogleOAuthResponse');
|
$routes->get('/oauth2callback', 'LoginController::receiveGoogleOAuthResponse');
|
||||||
$routes->get('/auth/google', 'LoginController::initiateGoogleOAuth');
|
$routes->get('/auth/google', 'LoginController::initiateGoogleOAuth');
|
||||||
|
|||||||
@ -4914,7 +4914,7 @@ class ClientController extends AdminController
|
|||||||
// $res = $empServiceController->excelFileFormatValidation(['file_id' => '865']);
|
// $res = $empServiceController->excelFileFormatValidation(['file_id' => '865']);
|
||||||
// $res = $empServiceController->excelFileDataValidation(['file_id' => '865']);
|
// $res = $empServiceController->excelFileDataValidation(['file_id' => '865']);
|
||||||
// $res = $empServiceController->employeesSIEnhanceProcess(['file_id' => '978']);
|
// $res = $empServiceController->employeesSIEnhanceProcess(['file_id' => '978']);
|
||||||
// $res = $empServiceController->employeeDisembark(['file_id' => '858']);
|
// $res = $empServiceController->employeeDisembark(['file_id' => '1681']); dd( $res);
|
||||||
|
|
||||||
$policyTransactionController = new PolicyTransactionController();
|
$policyTransactionController = new PolicyTransactionController();
|
||||||
// $res = $policyTransactionController->validateInsurerStatement(['file_id' => '17']);
|
// $res = $policyTransactionController->validateInsurerStatement(['file_id' => '17']);
|
||||||
@ -4925,9 +4925,9 @@ class ClientController extends AdminController
|
|||||||
// ----------EMP DATA SERVICE CONTROLLER--------------------------------------------------------------------------------
|
// ----------EMP DATA SERVICE CONTROLLER--------------------------------------------------------------------------------
|
||||||
|
|
||||||
$batch_data = [
|
$batch_data = [
|
||||||
'client_id' => 97,
|
'client_id' => 20,
|
||||||
'client_policy_id' => 6174,
|
'client_branch_id' => 72,
|
||||||
'client_branch_id' => 73,
|
'client_policy_id' => 127,
|
||||||
'insurer_or_tpa' => "insurer",
|
'insurer_or_tpa' => "insurer",
|
||||||
'event_type' => "deletion",
|
'event_type' => "deletion",
|
||||||
'actions' => "export",
|
'actions' => "export",
|
||||||
@ -4935,9 +4935,9 @@ class ClientController extends AdminController
|
|||||||
];
|
];
|
||||||
|
|
||||||
// $batch_data = [
|
// $batch_data = [
|
||||||
// 'client_id' => 29,
|
// 'client_id' => 20,
|
||||||
// 'client_policy_id' => 77,
|
// 'client_policy_id' => 77,
|
||||||
// 'client_branch_id' => 45,
|
// 'client_branch_id' => 72,
|
||||||
// 'insurer_or_tpa' => "insurer",
|
// 'insurer_or_tpa' => "insurer",
|
||||||
// // 'insurer_or_tpa' => "tpa",
|
// // 'insurer_or_tpa' => "tpa",
|
||||||
// 'event_type' => "si_enhancement",
|
// 'event_type' => "si_enhancement",
|
||||||
@ -4966,7 +4966,7 @@ class ClientController extends AdminController
|
|||||||
// $result = $EmpDataServiceController->importSIEnhancementValidation(['file_id' => 2496]); //for live
|
// $result = $EmpDataServiceController->importSIEnhancementValidation(['file_id' => 2496]); //for live
|
||||||
// $EmpDataServiceController->importInceptionUpdateTPAandUHID(['file_id' => 214]); //for live
|
// $EmpDataServiceController->importInceptionUpdateTPAandUHID(['file_id' => 214]); //for live
|
||||||
|
|
||||||
// $result = $this->employeePolicyModel->getDeletionEmployeeDataForExportExcel($batch_data);
|
// $result = $this->employeePolicyModel->getDeletionEmployeeDataForExportExcel($batch_data, 1); dd($result);
|
||||||
// $result = $this->employeePolicyModel->getSIEnhancementEmployeesDataForExportExcel($batch_data, 1);
|
// $result = $this->employeePolicyModel->getSIEnhancementEmployeesDataForExportExcel($batch_data, 1);
|
||||||
// return $this->downloadInsurerExcelExport($batch_data);
|
// return $this->downloadInsurerExcelExport($batch_data);
|
||||||
// dd($result); die;
|
// dd($result); die;
|
||||||
|
|||||||
@ -1370,27 +1370,32 @@ class EmployeeServiceController extends AdminController
|
|||||||
// echo '<br>START- ' . $row[2];
|
// echo '<br>START- ' . $row[2];
|
||||||
|
|
||||||
$employee = $this->employeeModel
|
$employee = $this->employeeModel
|
||||||
->where('emp_code', $row[1])
|
->select('employees.*, employee_polices.id as emp_policy_pk')
|
||||||
->where('name',$row[2])
|
->join('employee_polices', 'employees.id = employee_polices.employee_id')
|
||||||
->where('client_id',$file['client_id'])
|
->where('employees.emp_code', $row[1])
|
||||||
->where('client_branch_id',$file['client_branch_id'])
|
->where('employees.name',$row[2])
|
||||||
->where('emp_status !=','truncated')
|
->where('employees.client_id',$file['client_id'])
|
||||||
->where('is_active', 1)
|
->where('employees.client_branch_id',$file['client_branch_id'])
|
||||||
|
->where('employee_polices.client_policy_id',$file['policy_id'])
|
||||||
|
->where('employees.emp_status !=','truncated')
|
||||||
|
->where('employees.is_active', 1)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
// $employee = $this->employeeModel->where('emp_code', $row[1])->where('name',$row[2])->where('client_id',$file['client_id'])->first();
|
// $employee = $this->employeeModel->where('emp_code', $row[1])->where('name',$row[2])->where('client_id',$file['client_id'])->first();
|
||||||
// dd($employee);
|
// dd($employee);
|
||||||
if(is_array($employee) && count($employee))
|
if(is_array($employee) && count($employee))
|
||||||
{
|
{
|
||||||
// dd($employee);
|
// dd($employee);
|
||||||
$existing_endorsements = $this->empEndorsementModel->where('actions','d')
|
$existing_endorsements = $this->empEndorsementModel->where('actions','d')
|
||||||
->where('table_name','employee_polices')
|
->where('table_name','employee_polices')
|
||||||
->where('endorsement_id is null')
|
->where('endorsement_id is null')
|
||||||
->where('emp_code',$employee['emp_code'])
|
->where('emp_code',$employee['emp_code'])
|
||||||
->where('name',$employee['name'])
|
->where('name',$employee['name'])
|
||||||
->where('field_name','status')
|
->where('pk',$employee['emp_policy_pk'])
|
||||||
->where('status !=','truncated')
|
->where('field_name','status')
|
||||||
->where('is_active', 1)
|
->where('status !=','truncated')
|
||||||
->findAll();
|
->where('is_active', 1)
|
||||||
|
->findAll();
|
||||||
|
|
||||||
// dd($existing_endorsements);
|
// dd($existing_endorsements);
|
||||||
if(!count($existing_endorsements))
|
if(!count($existing_endorsements))
|
||||||
@ -1424,11 +1429,12 @@ class EmployeeServiceController extends AdminController
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
$this->myLogger->logme("error",'Existing endorsement pending for this employee : emp_code : {emp_code} - emp_name : {name}',['emp_code' => $row[1],'name' => $row[2]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->myLogger->logme("error",'{emp_code} - {name} not found',['emp_code' => $row[1],'name' => $row[2]]);
|
$this->myLogger->logme("error",'{emp_code} - {name} not found',['emp_code' => $row[1],'name' => $row[2]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,17 +6,20 @@ use CodeIgniter\HTTP\IncomingRequest;
|
|||||||
use CodeIgniter\HTTP\RequestInterface;
|
use CodeIgniter\HTTP\RequestInterface;
|
||||||
use CodeIgniter\HTTP\ResponseInterface;
|
use CodeIgniter\HTTP\ResponseInterface;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
use CodeIgniter\API\ResponseTrait;
|
||||||
|
|
||||||
use App\Models\UserModel;
|
use App\Models\UserModel;
|
||||||
use App\Models\AuthHistoryModel;
|
use App\Models\AuthHistoryModel;
|
||||||
|
|
||||||
class LoginController extends BaseController
|
class LoginController extends BaseController
|
||||||
{
|
{
|
||||||
|
use ResponseTrait;
|
||||||
|
|
||||||
public function index(){
|
public function index()
|
||||||
|
{
|
||||||
// $session_data = ['isLoggedIn' => True ,'userid' => '25'];
|
|
||||||
// set_session_data($session_data);
|
// $session_data = ['isLoggedIn' => True ,'userid' => '25'];
|
||||||
|
// set_session_data($session_data);
|
||||||
// $isLoggedIn = check_session();
|
// $isLoggedIn = check_session();
|
||||||
$isLoggedIn = check_session();
|
$isLoggedIn = check_session();
|
||||||
$hasCookie = check_cookie();
|
$hasCookie = check_cookie();
|
||||||
@ -26,7 +29,6 @@ class LoginController extends BaseController
|
|||||||
return view('login');
|
return view('login');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function receiveGoogleOAuthResponse()
|
public function receiveGoogleOAuthResponse()
|
||||||
{
|
{
|
||||||
$UserModel = new UserModel();
|
$UserModel = new UserModel();
|
||||||
@ -99,8 +101,8 @@ class LoginController extends BaseController
|
|||||||
return redirect()->to(base_url('login'));
|
return redirect()->to(base_url('login'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getUserDeviceInfo($userId, $type_of_user)
|
||||||
public function getUserDeviceInfo($userId, $type_of_user){
|
{
|
||||||
|
|
||||||
// Load the UserAgent library
|
// Load the UserAgent library
|
||||||
$userAgent = $this->request->getUserAgent();
|
$userAgent = $this->request->getUserAgent();
|
||||||
@ -129,5 +131,85 @@ class LoginController extends BaseController
|
|||||||
return $datd;
|
return $datd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function loginPos()
|
||||||
|
{
|
||||||
|
return view('pos_login');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getVerifyPosMobileNo()
|
||||||
|
{
|
||||||
|
$json = $this->request->getJSON();
|
||||||
|
$mobile = $json->mobile ?? null;
|
||||||
|
|
||||||
|
if (empty($mobile)) {
|
||||||
|
return $this->respond([
|
||||||
|
'status' => false,
|
||||||
|
'code' => 400,
|
||||||
|
'data' => 'Mobile number is required'
|
||||||
|
], 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
$cleanMobile = preg_replace('/^\+91/', '', $mobile); // Remove +91 if present
|
||||||
|
|
||||||
|
$userModel = new \App\Models\UserModel(); // Update namespace if needed
|
||||||
|
$user = $userModel->where('mobile', $cleanMobile)->first();
|
||||||
|
|
||||||
|
if (!$user) {
|
||||||
|
return $this->respond([
|
||||||
|
'status' => false,
|
||||||
|
'code' => 404,
|
||||||
|
'data' => 'User not found'
|
||||||
|
], 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->respond([
|
||||||
|
'status' => true,
|
||||||
|
'code' => 200,
|
||||||
|
'data' => $user // Optional: Replace with true or limited fields if needed
|
||||||
|
], 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getVerifiedPosUserData()
|
||||||
|
{
|
||||||
|
$json = $this->request->getJSON();
|
||||||
|
$mobile = $json->mobile ?? null;
|
||||||
|
|
||||||
|
if (!$mobile) {
|
||||||
|
return $this->respond([
|
||||||
|
'status' => false,
|
||||||
|
'code' => 400,
|
||||||
|
'message' => 'Mobile number is required'
|
||||||
|
], 200); // always return 200 with internal status
|
||||||
|
}
|
||||||
|
|
||||||
|
$cleanMobile = preg_replace('/^\+91/', '', $mobile);
|
||||||
|
|
||||||
|
$userModel = new \App\Models\UserModel();
|
||||||
|
$user = $userModel->where('mobile', $cleanMobile)->first();
|
||||||
|
|
||||||
|
if (!$user) {
|
||||||
|
return $this->respond([
|
||||||
|
'status' => false,
|
||||||
|
'code' => 404,
|
||||||
|
'message' => 'Employee not found'
|
||||||
|
], 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set session
|
||||||
|
session()->set([
|
||||||
|
'user_id' => $user['id'],
|
||||||
|
'user_name' => $user['first_name'],
|
||||||
|
'user_email' => $user['email'],
|
||||||
|
'is_logged_in' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $this->respond([
|
||||||
|
'status' => true,
|
||||||
|
'code' => 200,
|
||||||
|
'message' => 'Login successful',
|
||||||
|
'redirect_url' => base_url('/dashboard/view')
|
||||||
|
], 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
175
app/Views/pos_login.php
Normal file
175
app/Views/pos_login.php
Normal file
@ -0,0 +1,175 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Firebase OTP Login</title>
|
||||||
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
|
||||||
|
<style>
|
||||||
|
.otp-input {
|
||||||
|
width: 40px;
|
||||||
|
height: 45px;
|
||||||
|
font-size: 20px;
|
||||||
|
text-align: center;
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="container mt-5">
|
||||||
|
<div class="card mx-auto" style="max-width: 400px;">
|
||||||
|
<div class="card-body">
|
||||||
|
<h4 class="text-center">OTP Login</h4>
|
||||||
|
|
||||||
|
<div id="phone-section">
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Phone Number</label>
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<span class="input-group-text">+91</span>
|
||||||
|
</div>
|
||||||
|
<input type="text" id="phone_number" class="form-control" placeholder="XXXXXXXXXX" maxlength="10">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="recaptcha-container" class="my-2"></div>
|
||||||
|
<button class="btn btn-primary btn-block mt-3" id="send-otp-btn">Send OTP</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="otp-section" style="display: none;" class="mt-3">
|
||||||
|
<label>Enter OTP</label>
|
||||||
|
<div class="d-flex justify-content-between mb-3">
|
||||||
|
<input type="text" maxlength="1" class="form-control otp-input" id="otp-1">
|
||||||
|
<input type="text" maxlength="1" class="form-control otp-input" id="otp-2">
|
||||||
|
<input type="text" maxlength="1" class="form-control otp-input" id="otp-3">
|
||||||
|
<input type="text" maxlength="1" class="form-control otp-input" id="otp-4">
|
||||||
|
<input type="text" maxlength="1" class="form-control otp-input" id="otp-5">
|
||||||
|
<input type="text" maxlength="1" class="form-control otp-input" id="otp-6">
|
||||||
|
</div>
|
||||||
|
<button class="btn btn-success btn-block" id="verify-otp-btn">Verify OTP</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="module">
|
||||||
|
import { initializeApp } from "https://www.gstatic.com/firebasejs/12.0.0/firebase-app.js";
|
||||||
|
import { getAuth, signInWithPhoneNumber, RecaptchaVerifier } from "https://www.gstatic.com/firebasejs/12.0.0/firebase-auth.js";
|
||||||
|
|
||||||
|
const firebaseConfig = {
|
||||||
|
apiKey: "AIzaSyCSvDM5fG2blDBE69Cae3S-iYRwwNBy7xo",
|
||||||
|
authDomain: "nhance-ee8d1.firebaseapp.com",
|
||||||
|
projectId: "nhance-ee8d1",
|
||||||
|
storageBucket: "nhance-ee8d1.firebasestorage.app",
|
||||||
|
messagingSenderId: "1084115316849",
|
||||||
|
appId: "1:1084115316849:web:7ba35a83bf2570936c6bd0"
|
||||||
|
};
|
||||||
|
|
||||||
|
const app = initializeApp(firebaseConfig);
|
||||||
|
const auth = getAuth(app);
|
||||||
|
let confirmationResult;
|
||||||
|
let fullPhoneNumber = '';
|
||||||
|
|
||||||
|
window.onload = function () {
|
||||||
|
renderRecaptcha();
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderRecaptcha() {
|
||||||
|
window.recaptchaVerifier = new RecaptchaVerifier(auth, 'recaptcha-container', {
|
||||||
|
size: 'invisible',
|
||||||
|
callback: () => {
|
||||||
|
console.log('Invisible reCAPTCHA solved');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
window.recaptchaVerifier.render();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getVerifyPosMobileNo(mobile) {
|
||||||
|
try {
|
||||||
|
const response = await fetch("<?= base_url('getVerifyPosMobileNo') ?>", {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ mobile: mobile })
|
||||||
|
});
|
||||||
|
const result = await response.json();
|
||||||
|
return result.status;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error verifying mobile number:', error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById('send-otp-btn').addEventListener('click', async () => {
|
||||||
|
const number = document.getElementById('phone_number').value.trim();
|
||||||
|
if (!number.match(/^\d{10}$/)) {
|
||||||
|
alert('Enter a valid 10-digit phone number.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fullPhoneNumber = '+91' + number;
|
||||||
|
const isUserExists = await getVerifyPosMobileNo(fullPhoneNumber);
|
||||||
|
|
||||||
|
if (!isUserExists) {
|
||||||
|
alert('User not found.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
confirmationResult = await signInWithPhoneNumber(auth, fullPhoneNumber, window.recaptchaVerifier);
|
||||||
|
alert('OTP sent successfully!');
|
||||||
|
document.getElementById('phone-section').style.display = 'none';
|
||||||
|
document.getElementById('otp-section').style.display = 'block';
|
||||||
|
document.getElementById('otp-1').focus();
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error during signInWithPhoneNumber', error);
|
||||||
|
alert('Error sending OTP: ' + error.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById('verify-otp-btn').addEventListener('click', async () => {
|
||||||
|
const otpInputs = [...Array(6)].map((_, i) => document.getElementById(`otp-${i + 1}`).value).join('');
|
||||||
|
if (otpInputs.length !== 6) {
|
||||||
|
alert('Please enter the 6-digit OTP.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!confirmationResult) {
|
||||||
|
alert('No OTP request in progress.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = await confirmationResult.confirm(otpInputs);
|
||||||
|
const user = result.user;
|
||||||
|
const response = await fetch("<?= base_url('getVerifiedPosUserData') ?>", {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ mobile: fullPhoneNumber })
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
if (data.status && data.redirect_url) {
|
||||||
|
window.location.href = data.redirect_url;
|
||||||
|
} else {
|
||||||
|
alert(data.message || 'Login failed.');
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('OTP verification error', error);
|
||||||
|
alert('Invalid OTP: ' + error.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Auto move to next input
|
||||||
|
for (let i = 1; i <= 6; i++) {
|
||||||
|
const input = document.getElementById(`otp-${i}`);
|
||||||
|
input.addEventListener('input', () => {
|
||||||
|
if (input.value.length === 1 && i < 6) {
|
||||||
|
document.getElementById(`otp-${i + 1}`).focus();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
Loading…
Reference in New Issue
Block a user