Compare commits
17 Commits
admin_feat
...
fetch-from
| Author | SHA1 | Date | |
|---|---|---|---|
| 785db2c8a4 | |||
| b1cf06ef08 | |||
| 7e852763ff | |||
| c5b5927398 | |||
| c8adc3688a | |||
| 69c5ccba1d | |||
| c3875afbd2 | |||
| 9446abd88b | |||
| 7cf19000d1 | |||
| 61b85abdd1 | |||
| 1e831acfe2 | |||
| bf06706b29 | |||
| a04830cdb2 | |||
| 12f0881c9b | |||
| 4c63ccf3ae | |||
| 60cb0076f1 | |||
| b68c8a08c2 |
@@ -168,6 +168,23 @@ async function tpin(req, res) {
|
||||
}
|
||||
}
|
||||
|
||||
async function transPassword(req, res) {
|
||||
const customerNo = req.user;
|
||||
try {
|
||||
const user = await authService.findUserByCustomerNo(customerNo);
|
||||
if (!user) return res.status(404).json({ message: 'USER_NOT_FOUND' });
|
||||
if (!user.transaction_password) {
|
||||
return res.json({ transPasswordSet: false });
|
||||
} else {
|
||||
return res.json({ transPasswordSet: true });
|
||||
}
|
||||
} catch (err) {
|
||||
logger.error(err, 'error occured while checking transaction password');
|
||||
res.status(500).json({ error: 'something went wrong' });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async function setTpin(req, res) {
|
||||
const customerNo = req.user;
|
||||
try {
|
||||
@@ -221,12 +238,30 @@ async function setLoginPassword(req, res) {
|
||||
}
|
||||
}
|
||||
|
||||
async function setTransactionPassword(req, res) {
|
||||
async function setTransPassword(req, res) {
|
||||
const customerNo = req.user;
|
||||
try {
|
||||
const user = await authService.findUserByCustomerNo(customerNo);
|
||||
if (!user) return res.status(404).json({ error: 'USER_NOT_FOUND' });
|
||||
const { transaction_password } = req.body;
|
||||
// if (user.transaction_password) {
|
||||
// const isMatchWithOldPassword = await comparePassword(
|
||||
// transaction_password,
|
||||
// user.transaction_password
|
||||
// );
|
||||
// if (isMatchWithOldPassword)
|
||||
// return res.status(500).json({
|
||||
// error: 'New transaction Password will be different from Previous Password',
|
||||
// });
|
||||
// }
|
||||
const isMatchWithLoginPassword = await comparePassword(
|
||||
transaction_password,
|
||||
user.password_hash
|
||||
);
|
||||
if (isMatchWithLoginPassword)
|
||||
return res.status(500).json({
|
||||
error: 'New transaction Password will be different from Login Password',
|
||||
});
|
||||
authService.setTransactionPassword(customerNo, transaction_password);
|
||||
return res.json({ message: 'Transaction Password set' });
|
||||
} catch (error) {
|
||||
@@ -291,6 +326,14 @@ async function changeTransPassword(req, res) {
|
||||
error:
|
||||
'New Transaction Password will be different from Previous Transaction Password',
|
||||
});
|
||||
const isMatchWithLoginPassword = await comparePassword(
|
||||
newTPsw,
|
||||
user.password_hash
|
||||
);
|
||||
if (isMatchWithLoginPassword)
|
||||
return res.status(500).json({
|
||||
error: 'New transaction Password will be different from Login Password',
|
||||
});
|
||||
authService.changeTransPassword(customerNo, newTPsw);
|
||||
return res.json({
|
||||
message: 'New Transaction Password changed successfully',
|
||||
@@ -395,7 +438,8 @@ module.exports = {
|
||||
setTpin,
|
||||
changeTpin,
|
||||
setLoginPassword,
|
||||
setTransactionPassword,
|
||||
transPassword,
|
||||
setTransPassword,
|
||||
fetchUserDetails,
|
||||
changeLoginPassword,
|
||||
changeTransPassword,
|
||||
|
||||
@@ -114,6 +114,12 @@ async function SendOtp(req, res) {
|
||||
case 'TLIMIT_SET':
|
||||
message = templates.TLIMIT_SET(amount);
|
||||
break;
|
||||
case 'LPWORD_CHANGE':
|
||||
message = templates.LPWORD_CHANGE;
|
||||
break;
|
||||
case 'TPWORD_CHANGE':
|
||||
message = templates.TPWORD_CHANGE;
|
||||
break;
|
||||
default:
|
||||
return res.status(400).json({ error: 'Invalid OTP type' });
|
||||
}
|
||||
@@ -194,6 +200,7 @@ async function sendForSetPassword(req, res) {
|
||||
}
|
||||
);
|
||||
await setJson(`otp:${mobileNumber}`, otp, 300);
|
||||
logger.info(`Sent OTP [${otp}] to ${mobileNumber}`);
|
||||
return res.status(200).json({ message: 'OTP_SENT' });
|
||||
} catch (err) {
|
||||
logger.error(err, 'Error sending OTP');
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
const { logger } = require('../util/logger');
|
||||
|
||||
function verifyClient(req, res, next) {
|
||||
console.log('printing headers');
|
||||
console.log(req.headers);
|
||||
const clientHeader = req.headers['x-login-type'];
|
||||
|
||||
if (!clientHeader || (clientHeader !== 'MB' && clientHeader !== 'IB' && clientHeader !== 'eMandate' && clientHeader !=='Admin')) {
|
||||
if (!clientHeader || (clientHeader !== 'MB' && clientHeader !== 'IB' && clientHeader !== 'NPCI' && clientHeader !== 'eMandate' && clientHeader !=='Admin')) {
|
||||
logger.error(
|
||||
`Invalid or missing client header. Expected 'MB' or 'IB'. Found ${clientHeader}`
|
||||
);
|
||||
|
||||
@@ -7,6 +7,8 @@ const router = express.Router();
|
||||
router.post('/login', adminAuthController.login);
|
||||
router.get('/admin_details', adminAuthenticate, adminAuthController.fetchAdminDetails);
|
||||
router.get('/fetch/customer_details',adminAuthenticate,adminAuthController.getUserDetails);
|
||||
|
||||
// User configuration
|
||||
router.post('/user/rights',adminAuthenticate,adminAuthController.UserRights);
|
||||
router.get('/user/rights',adminAuthenticate,adminAuthController.getUserRights);
|
||||
router.post('/user/unlock',adminAuthenticate,adminAuthController.handleUnlockUser);
|
||||
|
||||
@@ -6,7 +6,7 @@ const router = express.Router();
|
||||
|
||||
const atmRoute = async (req, res) => {
|
||||
try {
|
||||
const query_str = 'SELECT * FROM atm';
|
||||
const query_str = 'SELECT * FROM atm_details';
|
||||
const result = await db.query(query_str);
|
||||
return res.json(result.rows);
|
||||
} catch (error) {
|
||||
|
||||
@@ -6,20 +6,24 @@ const router = express.Router();
|
||||
|
||||
router.post('/login', authController.login);
|
||||
router.get('/user_details', authenticate, authController.fetchUserDetails);
|
||||
|
||||
router.get('/tpin', authenticate, authController.tpin);
|
||||
router.post('/tpin', authenticate, authController.setTpin);
|
||||
router.post('/change/tpin', authenticate, authController.changeTpin);
|
||||
|
||||
router.post('/login_password', authenticate, authController.setLoginPassword);
|
||||
router.post(
|
||||
'/transaction_password',
|
||||
authenticate,
|
||||
authController.setTransactionPassword
|
||||
);
|
||||
router.post(
|
||||
'/change/login_password',
|
||||
authenticate,
|
||||
authController.changeLoginPassword
|
||||
);
|
||||
|
||||
router.get('/transaction_password', authenticate, authController.transPassword);
|
||||
router.post(
|
||||
'/transaction_password',
|
||||
authenticate,
|
||||
authController.setTransPassword
|
||||
);
|
||||
router.post(
|
||||
'/change/transaction_password',
|
||||
authenticate,
|
||||
|
||||
73
src/routes/cheque.route.js
Normal file
73
src/routes/cheque.route.js
Normal file
@@ -0,0 +1,73 @@
|
||||
const express = require('express');
|
||||
const { logger } = require('../util/logger');
|
||||
const axios = require('axios');
|
||||
const paymentSecretValidator = require('../validators/payment.secret.validator');
|
||||
|
||||
const chequeEnquiryRoute = async (req, res) => {
|
||||
const { accountNumber, instrumentType } = req.query;
|
||||
if (!accountNumber || !instrumentType) {
|
||||
return res.status(400).json({ error: 'BAD_REQUEST' });
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await axios.get('http://localhost:8444/kccb/cheque', {
|
||||
params: { accountno: accountNumber, instrType: instrumentType },
|
||||
});
|
||||
|
||||
return res.json(response.data);
|
||||
} catch (error) {
|
||||
logger.error('Unable to fetch cheque data: ', error);
|
||||
return res.status(500).json({ error: 'INTERNAL_SERVER_ERROR' });
|
||||
}
|
||||
};
|
||||
|
||||
const chequeStopRoute = async (req, res) => {
|
||||
const {
|
||||
accountNumber,
|
||||
instrumentType,
|
||||
stopFromChequeNo,
|
||||
stopToChequeNo,
|
||||
stopIssueDate,
|
||||
stopExpiryDate,
|
||||
stopAmount,
|
||||
stopComment,
|
||||
chqIssueDate,
|
||||
} = req.body;
|
||||
|
||||
if (!accountNumber || !instrumentType || !stopFromChequeNo) {
|
||||
console.log('missing');
|
||||
return res.status(400).json({ error: 'BAD_REQUEST' });
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await axios.post(
|
||||
'http://localhost:8444/kccb/chequeSetStop',
|
||||
{
|
||||
accountno: accountNumber,
|
||||
stopFromChequeNo: stopFromChequeNo,
|
||||
instrType: instrumentType,
|
||||
stopToChequeNo: stopToChequeNo,
|
||||
stopIssueDate: stopIssueDate,
|
||||
stopExpiryDate: stopExpiryDate,
|
||||
stopAmount: stopAmount,
|
||||
stopComment: stopComment,
|
||||
chqIssueDate: chqIssueDate,
|
||||
}
|
||||
);
|
||||
|
||||
console.log('response from stop cheque api: ', response.data);
|
||||
return res.json(response.data);
|
||||
} catch (error) {
|
||||
logger.error('Unable to fetch cheque data: ', error);
|
||||
return res.status(500).json({ error: 'INTERNAL_SERVER_ERROR' });
|
||||
}
|
||||
};
|
||||
const enquiryRouter = express.Router();
|
||||
const stopRouter = express.Router();
|
||||
const router = express.Router();
|
||||
enquiryRouter.get('/enquiry', chequeEnquiryRoute);
|
||||
stopRouter.use(paymentSecretValidator);
|
||||
stopRouter.post('/stop', chequeStopRoute);
|
||||
router.use(enquiryRouter, stopRouter);
|
||||
|
||||
module.exports = router;
|
||||
@@ -8,17 +8,20 @@ const emandateData = async (req, res) => {
|
||||
return res.status(404).json({ error: 'DATA NOT FOUND FROM CLIENT' })
|
||||
try {
|
||||
const reqData = { data, mandateRequest, mandateType };
|
||||
if (customer_no) {
|
||||
reqData.customer_no = customer_no;
|
||||
}
|
||||
const response = await axios.post('http://192.168.1.166:9992/kccb/validation', reqData,
|
||||
{
|
||||
headers: { 'Content-Type': 'application/json', },
|
||||
}
|
||||
);
|
||||
logger.info("Data validate");
|
||||
return response.data;
|
||||
logger.info(response.data, "Data validate");
|
||||
return res.json({ data: response.data });
|
||||
} catch (error) {
|
||||
logger.error(error, 'error occured while E-Mandate validation');
|
||||
return res.status(500).json({ error: 'INTERNAL_SERVER_ERROR' });
|
||||
}
|
||||
};
|
||||
router.post('/validation', emandateData);
|
||||
module.exports = router;
|
||||
module.exports = router;
|
||||
|
||||
@@ -13,17 +13,17 @@ const impsRoute = require('./imps.route');
|
||||
const branchRoute = require('./branch.route');
|
||||
const atmRoute = require('./atm.route');
|
||||
const { npciResponse } = require('../controllers/npci.controller');
|
||||
const {
|
||||
simDetailsResponse,
|
||||
simDetailsRequest,
|
||||
} = require('./sim_verfify.route.js');
|
||||
const otp = require('./otp.route');
|
||||
<<<<<<< HEAD
|
||||
const reports =require('./report.route');
|
||||
|
||||
=======
|
||||
const reports = require('./report.route');
|
||||
const eMandate = require('./emandate.route');
|
||||
>>>>>>> 7e162e741d4d126fd029b1875bd5e4e0d3c460cf
|
||||
const chequeRoute = require('./cheque.route');
|
||||
const router = express.Router();
|
||||
|
||||
router.use('/auth', authRoute);
|
||||
router.use('/auth/admin', adminAuthRoute);
|
||||
router.use('/customer', authenticate, detailsRoute);
|
||||
router.use('/transactions/account/:accountNo', authenticate, transactionRoute);
|
||||
router.use('/payment/transfer', authenticate, transferRoute);
|
||||
@@ -32,10 +32,18 @@ router.use('/payment/rtgs', authenticate, rtgsRoute);
|
||||
router.use('/payment/imps', authenticate, impsRoute);
|
||||
router.use('/beneficiary', authenticate, beneficiaryRoute);
|
||||
router.use('/npci/beneficiary-response', npciResponse);
|
||||
router.use('/report',adminAuthenticate,reports);
|
||||
router.use('/otp', otp);
|
||||
router.use('/e-mandate', authenticate, eMandate);
|
||||
router.use('/branch', authenticate, branchRoute);
|
||||
router.use('/atm', authenticate, atmRoute);
|
||||
router.use('/cheque', authenticate, chequeRoute);
|
||||
|
||||
// OTP
|
||||
router.use('/otp', otp);
|
||||
|
||||
// Admin APIs
|
||||
router.use('/auth/admin', adminAuthRoute);
|
||||
router.use('/report', adminAuthenticate, reports);
|
||||
router.post('/sim-details', simDetailsResponse);
|
||||
router.post('/sim-details-verify', simDetailsRequest);
|
||||
|
||||
module.exports = router;
|
||||
|
||||
69
src/routes/sim_verfify.route.js
Normal file
69
src/routes/sim_verfify.route.js
Normal file
@@ -0,0 +1,69 @@
|
||||
const db = require('../config/db');
|
||||
const { getJson, setJson } = require('../config/redis');
|
||||
const { logger } = require('../util/logger');
|
||||
const customerController = require('../controllers/customer_details.controller');
|
||||
|
||||
async function simDetailsResponse(req, res) {
|
||||
const { phoneNo, uuid } = req.body;
|
||||
try {
|
||||
console.log(`phone no from sms: ${phoneNo}`);
|
||||
console.log(`message body from sms: ${uuid}`);
|
||||
await setJson(uuid, phoneNo);
|
||||
} catch (error) {
|
||||
logger.error(error, 'error processing sim details response');
|
||||
}
|
||||
res.json({ message: 'OK' });
|
||||
}
|
||||
|
||||
async function simDetailsRequest(req, res) {
|
||||
const { cifNo, uuid } = req.body;
|
||||
try {
|
||||
const customerDetails = await customerController.getDetails(cifNo);
|
||||
const phoneNo = customerDetails[0].mobileno?.slice(-10);
|
||||
const phoneNoFromVendor = await pollRedisKey(uuid);
|
||||
if (!phoneNoFromVendor) {
|
||||
return res.json({ error: 'Could not verify phone number' });
|
||||
}
|
||||
const strippedPhoneNo = phoneNoFromVendor.slice(-10);
|
||||
console.log('phone no from CBS: ', phoneNo);
|
||||
console.log('phone no from SIM: ', strippedPhoneNo);
|
||||
if (phoneNo === strippedPhoneNo) {
|
||||
return res.json({ status: 'VERIFIED' });
|
||||
}
|
||||
return res.json({ status: 'NOT_VERIFIED' });
|
||||
} catch (error) {
|
||||
logger.error(error, 'sim verification failed');
|
||||
res.status(500).json({ error: 'SIM verification failed' });
|
||||
}
|
||||
}
|
||||
|
||||
async function pollRedisKey(key) {
|
||||
const timeout = 2 * 60 * 1000;
|
||||
const interval = 2000;
|
||||
const startTime = Date.now();
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const poll = async () => {
|
||||
try {
|
||||
const phoneNo = await getJson(key);
|
||||
if (phoneNo !== null) {
|
||||
console.log(phoneNo, 'payload from redis');
|
||||
return resolve(phoneNo);
|
||||
}
|
||||
|
||||
if (Date.now() - startTime >= timeout) {
|
||||
return resolve(null);
|
||||
}
|
||||
|
||||
console.log('not found retrying for uuid');
|
||||
|
||||
setTimeout(poll, interval);
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
}
|
||||
};
|
||||
|
||||
poll();
|
||||
});
|
||||
}
|
||||
module.exports = { simDetailsResponse, simDetailsRequest };
|
||||
@@ -53,12 +53,18 @@ const templates = {
|
||||
|
||||
USERNAME_SAVED: (PreferName) =>
|
||||
`Dear Customer, Your Preferred Name -${PreferName} has been updated successfully. If this change was not made by you, please contact our support team immediately.`,
|
||||
|
||||
TLIMIT :(otp) =>
|
||||
|
||||
TLIMIT: (otp) =>
|
||||
`Dear Customer,Please complete the transaction limit set with OTP -${otp}. -KCCB`,
|
||||
|
||||
TLIMIT_SET :(amount) =>
|
||||
TLIMIT_SET: (amount) =>
|
||||
`Dear Customer,Your transaction limit for Internet Banking is set to Rs ${amount}. -KCCB`,
|
||||
|
||||
LPWORD_CHANGE:
|
||||
`Dear Customer, Your Login password has been successfully updated. If you did not initiate this, please contact your nearest branch immediately. -KCCB`,
|
||||
|
||||
TPWORD_CHANGE:
|
||||
`Dear Customer, Your transaction password has been successfully updated. If you did not initiate this, please contact your nearest branch immediately. -KCCB`,
|
||||
};
|
||||
|
||||
module.exports = templates;
|
||||
Reference in New Issue
Block a user