feat: add message template for e-mandate
This commit is contained in:
@@ -7,6 +7,7 @@ const { comparePassword } = require('../util/hash');
|
|||||||
|
|
||||||
async function login(req, res) {
|
async function login(req, res) {
|
||||||
const { customerNo, password } = req.body;
|
const { customerNo, password } = req.body;
|
||||||
|
const loginType = req.headers['x-login-type'] || 'standard';
|
||||||
|
|
||||||
if (!customerNo || !password) {
|
if (!customerNo || !password) {
|
||||||
return res
|
return res
|
||||||
@@ -39,9 +40,10 @@ async function login(req, res) {
|
|||||||
currentTime,
|
currentTime,
|
||||||
customerNo,
|
customerNo,
|
||||||
]);
|
]);
|
||||||
|
logger.info(`Login successful | Type: ${loginType}`);
|
||||||
res.json({ token, FirstTimeLogin, loginPswExpiry, rights });
|
res.json({ token, FirstTimeLogin, loginPswExpiry, rights });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error(err, 'login failed');
|
logger.error(err, `login failed | Type: ${loginType}`);
|
||||||
res.status(500).json({ error: 'something went wrong' });
|
res.status(500).json({ error: 'something went wrong' });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,6 +82,10 @@ async function SendOtp(req, res) {
|
|||||||
case 'RIGHT_UPDATE':
|
case 'RIGHT_UPDATE':
|
||||||
message = templates.RIGHT_UPDATE;
|
message = templates.RIGHT_UPDATE;
|
||||||
break;
|
break;
|
||||||
|
case 'EMandate':
|
||||||
|
otp = generateOTP(6);
|
||||||
|
message = templates.EMandate(otp);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return res.status(400).json({ error: 'Invalid OTP type' });
|
return res.status(400).json({ error: 'Invalid OTP type' });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ const templates = {
|
|||||||
|
|
||||||
RIGHT_UPDATE:
|
RIGHT_UPDATE:
|
||||||
`Dear Customer, Your CIF rights have been updated. Please log in again to access the features. -KCCB`,
|
`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;
|
module.exports = templates;
|
||||||
Reference in New Issue
Block a user