added migrated user message in auth controller
This commit is contained in:
@@ -17,7 +17,10 @@ async function login(req, res) {
|
|||||||
try {
|
try {
|
||||||
const user = await authService.validateUser(customerNo, password);
|
const user = await authService.validateUser(customerNo, password);
|
||||||
if (!user || !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);
|
const FirstTimeLogin = await authService.CheckFirstTimeLogin(customerNo);
|
||||||
// For registration : if try to login first time after 7 days.
|
// For registration : if try to login first time after 7 days.
|
||||||
if (FirstTimeLogin && dayjs(user.created_at).diff(currentTime, "day") > 8)
|
if (FirstTimeLogin && dayjs(user.created_at).diff(currentTime, "day") > 8)
|
||||||
|
|||||||
Reference in New Issue
Block a user