feat: login IB by two step verification
chore: add message template
This commit is contained in:
@@ -10,6 +10,7 @@ const templates = require('../util/sms_template');
|
||||
// Send OTP
|
||||
async function SendOtp(req, res) {
|
||||
const {
|
||||
username,
|
||||
mobileNumber,
|
||||
type,
|
||||
amount,
|
||||
@@ -33,6 +34,10 @@ async function SendOtp(req, res) {
|
||||
let otp = null;
|
||||
// Pick template based on type
|
||||
switch (type) {
|
||||
case 'LOGIN_OTP':
|
||||
otp = generateOTP(6);
|
||||
message = templates.LOGIN_OTP(otp, username);
|
||||
break;
|
||||
case 'IMPS':
|
||||
otp = generateOTP(6);
|
||||
message = templates.IMPS(otp);
|
||||
@@ -52,6 +57,10 @@ async function SendOtp(req, res) {
|
||||
case 'BENEFICIARY_SUCCESS':
|
||||
message = templates.BENEFICIARY_SUCCESS(beneficiary);
|
||||
break;
|
||||
case 'BENEFICIARY_DELETE':
|
||||
otp = generateOTP(6);
|
||||
message = templates.BENEFICIARY_DELETE(otp, beneficiary);
|
||||
break;
|
||||
case 'NOTIFICATION':
|
||||
message = templates.NOTIFICATION(acctFrom, acctTo, amount, ref, date);
|
||||
break;
|
||||
@@ -71,6 +80,10 @@ async function SendOtp(req, res) {
|
||||
otp = generateOTP(6);
|
||||
message = templates.CHANGE_TPWORD(otp);
|
||||
break;
|
||||
case 'SET_TPWORD':
|
||||
otp = generateOTP(6);
|
||||
message = templates.SET_TPWORD(otp);
|
||||
break;
|
||||
case 'CHANGE_MPIN':
|
||||
otp = generateOTP(6);
|
||||
message = templates.CHANGE_MPIN(otp);
|
||||
@@ -104,10 +117,8 @@ async function SendOtp(req, res) {
|
||||
if (message.includes('OTP')) {
|
||||
await setJson(`otp:${mobileNumber}`, otp, 300);
|
||||
}
|
||||
|
||||
logger.info(`Sent OTP [${otp}] for type [${type}] to ${mobileNumber}`);
|
||||
}
|
||||
|
||||
return res.status(200).json({ message: 'Message sent successfully' });
|
||||
} catch (err) {
|
||||
logger.error(err, 'Error sending OTP');
|
||||
|
||||
Reference in New Issue
Block a user