feat: default password for migrated users
This commit is contained in:
@@ -39,6 +39,9 @@ async function login(req, res) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const userCheck = await authService.findUserByCustomerNo(customerNo);
|
const userCheck = await authService.findUserByCustomerNo(customerNo);
|
||||||
|
if (!userCheck) {
|
||||||
|
return res.status(404).json({ error: 'customer not found' });
|
||||||
|
}
|
||||||
|
|
||||||
if (loginType.toUpperCase() === 'IB') {
|
if (loginType.toUpperCase() === 'IB') {
|
||||||
// check DB locked flag
|
// check DB locked flag
|
||||||
@@ -52,9 +55,13 @@ async function login(req, res) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// --- Step 2: Check migration status
|
// --- Step 2: Check migration status
|
||||||
const isMigratedUser = await authService.isMigratedUser(customerNo);
|
const migratedPassword = `${userCheck.customer_no}@KCCB`;
|
||||||
if (isMigratedUser)
|
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' });
|
return res.status(401).json({ error: 'MIGRATED_USER_HAS_NO_PASSWORD' });
|
||||||
|
}
|
||||||
|
|
||||||
// --- Step 3: Validate credentials ---
|
// --- Step 3: Validate credentials ---
|
||||||
const user = await authService.validateUser(customerNo, password);
|
const user = await authService.validateUser(customerNo, password);
|
||||||
|
|||||||
Reference in New Issue
Block a user