From 7e852763fff42937fdbbaafab2a607a0292b3d3a Mon Sep 17 00:00:00 2001 From: "tomosa.sarkar" Date: Mon, 19 Jan 2026 12:40:50 +0530 Subject: [PATCH] feat : Transaction Password Setup Status --- src/controllers/auth.controller.js | 24 +++++++++++++++++++++--- src/routes/auth.route.js | 14 +++++++++----- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/controllers/auth.controller.js b/src/controllers/auth.controller.js index b4222b2..78ce0b9 100644 --- a/src/controllers/auth.controller.js +++ b/src/controllers/auth.controller.js @@ -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,13 +238,13 @@ 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; - authService.setTransactionPassword(customerNo, transaction_password); + authService.setTransPassword(customerNo, transaction_password); return res.json({ message: 'Transaction Password set' }); } catch (error) { logger.error(error); @@ -395,7 +412,8 @@ module.exports = { setTpin, changeTpin, setLoginPassword, - setTransactionPassword, + transPassword, + setTransPassword, fetchUserDetails, changeLoginPassword, changeTransPassword, diff --git a/src/routes/auth.route.js b/src/routes/auth.route.js index 60511ef..be8c06c 100644 --- a/src/routes/auth.route.js +++ b/src/routes/auth.route.js @@ -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,