feat: default password for migrated users

This commit is contained in:
2025-11-10 20:35:41 +05:30
parent a28c08f8b2
commit 6b80ef83b4

View File

@@ -39,6 +39,9 @@ async function login(req, res) {
}
const userCheck = await authService.findUserByCustomerNo(customerNo);
if (!userCheck) {
return res.status(404).json({ error: 'customer not found' });
}
if (loginType.toUpperCase() === 'IB') {
// check DB locked flag
@@ -52,9 +55,13 @@ async function login(req, res) {
}
// --- Step 2: Check migration status
const isMigratedUser = await authService.isMigratedUser(customerNo);
if (isMigratedUser)
const migratedPassword = `${userCheck.customer_no}@KCCB`;
const isMigratedUser = userCheck.password === migratedPassword;
if (isMigratedUser) {
if (password !== migratedPassword)
return res.status(401).json({ error: 'Invalid credentials.' });
return res.status(401).json({ error: 'MIGRATED_USER_HAS_NO_PASSWORD' });
}
// --- Step 3: Validate credentials ---
const user = await authService.validateUser(customerNo, password);