added migrated user message in auth controller

This commit is contained in:
asif
2025-09-10 20:04:12 +05:30
parent 3f90a793fe
commit d492c43427

View File

@@ -17,7 +17,10 @@ async function login(req, res) {
try {
const user = await authService.validateUser(customerNo, password);
if (!user || !password)
return res.status(401).json({ error: 'invalid credentials' });
return res.status(401).json({ error: 'INVALID_CREDENTIALS' });
if (user?.password_hash === 'o')
return res.status(401).json({ error: 'MIGRATED_USER_HAS_NO_PASSWORD' });
const token = generateToken(user.customer_no, '9d');
const FirstTimeLogin = await authService.CheckFirstTimeLogin(customerNo);
// For registration : if try to login first time after 7 days.
if (FirstTimeLogin && dayjs(user.created_at).diff(currentTime, "day") > 8)