From edbeca3fd2a5695ac1f4fe022be639fb32346784 Mon Sep 17 00:00:00 2001 From: "tomosa.sarkar" Date: Thu, 25 Sep 2025 12:07:02 +0530 Subject: [PATCH] feat: add message template for e-mandate --- src/controllers/auth.controller.js | 4 +++- src/controllers/otp.controller.js | 4 ++++ src/util/sms_template.js | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/controllers/auth.controller.js b/src/controllers/auth.controller.js index ee1c7d4..909d48a 100644 --- a/src/controllers/auth.controller.js +++ b/src/controllers/auth.controller.js @@ -7,6 +7,7 @@ const { comparePassword } = require('../util/hash'); async function login(req, res) { const { customerNo, password } = req.body; + const loginType = req.headers['x-login-type'] || 'standard'; if (!customerNo || !password) { return res @@ -39,9 +40,10 @@ async function login(req, res) { currentTime, customerNo, ]); + logger.info(`Login successful | Type: ${loginType}`); res.json({ token, FirstTimeLogin, loginPswExpiry, rights }); } catch (err) { - logger.error(err, 'login failed'); + logger.error(err, `login failed | Type: ${loginType}`); res.status(500).json({ error: 'something went wrong' }); } } diff --git a/src/controllers/otp.controller.js b/src/controllers/otp.controller.js index 2069aa8..b88775e 100644 --- a/src/controllers/otp.controller.js +++ b/src/controllers/otp.controller.js @@ -82,6 +82,10 @@ async function SendOtp(req, res) { case 'RIGHT_UPDATE': message = templates.RIGHT_UPDATE; break; + case 'EMandate': + otp = generateOTP(6); + message = templates.EMandate(otp); + break; default: return res.status(400).json({ error: 'Invalid OTP type' }); } diff --git a/src/util/sms_template.js b/src/util/sms_template.js index 2998655..dd721e8 100644 --- a/src/util/sms_template.js +++ b/src/util/sms_template.js @@ -36,6 +36,9 @@ const templates = { RIGHT_UPDATE: `Dear Customer, Your CIF rights have been updated. Please log in again to access the features. -KCCB`, + + EMandate: (otp) => + `Dear Customer, Your OTP for e-Mandate is ${otp}.It is valid for 1 minute.Do not share this OTP with anyone. -KCCB` }; module.exports = templates; \ No newline at end of file