feat : admin feature

This commit is contained in:
2025-08-08 13:06:08 +05:30
parent b88e00f758
commit cd1193c746
9 changed files with 148 additions and 7 deletions

View File

@@ -2,9 +2,9 @@ const jwt = require('jsonwebtoken');
const { jwtSecret } = require('../config/config');
const { logger } = require('./logger');
function generateToken(customerNo, expiresIn = '10d') {
logger.info({ customerNo }, 'payload to encode');
return jwt.sign({ customerNo }, jwtSecret, { expiresIn });
function generateToken(customerNo, role = 'user', expiresIn = '10d') {
logger.info({ customerNo, role }, 'payload to encode');
return jwt.sign({ customerNo, role }, jwtSecret, { expiresIn });
}
function verifyToken(token) {