fix: Add X-header for EMandate.

wip: add message template
This commit is contained in:
2025-10-29 15:34:54 +05:30
parent 654b4ddaf7
commit f807f62660
5 changed files with 17 additions and 2 deletions

View File

@@ -3,6 +3,7 @@
"MPIN", "MPIN",
"occured", "occured",
"otpgenerator", "otpgenerator",
"TLIMIT",
"tpassword", "tpassword",
"tpin", "tpin",
"TPWORD" "TPWORD"

View File

@@ -6,5 +6,6 @@ dotenv.config({ path: path.resolve(__dirname, '../../.env') });
module.exports = { module.exports = {
port: process.env.PORT || 8080, port: process.env.PORT || 8080,
dbUrl: process.env.DATABASE_URL, dbUrl: process.env.DATABASE_URL,
redisUrl: process.env.REDIS_URL,
jwtSecret: process.env.JWT_SECRET, jwtSecret: process.env.JWT_SECRET,
}; };

View File

@@ -107,6 +107,13 @@ async function SendOtp(req, res) {
case 'USERNAME_SAVED': case 'USERNAME_SAVED':
message = templates.USERNAME_SAVED(PreferName); message = templates.USERNAME_SAVED(PreferName);
break; break;
case 'TLIMIT':
otp = generateOTP(6);
message = templates.TLIMIT(otp);
break;
case 'TLIMIT_SET':
message = templates.TLIMIT_SET(amount);
break;
default: default:
return res.status(400).json({ error: 'Invalid OTP type' }); return res.status(400).json({ error: 'Invalid OTP type' });
} }

View File

@@ -3,7 +3,7 @@ const { logger } = require('../util/logger');
function verifyClient(req, res, next) { function verifyClient(req, res, next) {
const clientHeader = req.headers['x-login-type']; const clientHeader = req.headers['x-login-type'];
if (!clientHeader || (clientHeader !== 'MB' && clientHeader !== 'IB')) { if (!clientHeader || (clientHeader !== 'MB' && clientHeader !== 'IB' && clientHeader !== 'eMandate')) {
logger.error( logger.error(
`Invalid or missing client header. Expected 'MB' or 'IB'. Found ${clientHeader}` `Invalid or missing client header. Expected 'MB' or 'IB'. Found ${clientHeader}`
); );

View File

@@ -52,7 +52,13 @@ const templates = {
`Dear Customer, Your OTP for updating your Preferred Name is ${otp}. It is valid for 1 minute. Do not share this OTP with anyone. -KCCB`, `Dear Customer, Your OTP for updating your Preferred Name is ${otp}. It is valid for 1 minute. Do not share this OTP with anyone. -KCCB`,
USERNAME_SAVED: (PreferName) => 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.` `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) =>
`Dear Customer,Please complete the transaction limit set with ${otp}. -KCCB`,
TLIMIT_SET :(amount) =>
`Dear Customer,Your transaction limit for Internet Banking is set to Rs ${amount}. -KCCB`,
}; };
module.exports = templates; module.exports = templates;