update: auth login with username or email

This commit is contained in:
2025-10-09 03:36:17 +07:00
parent fdeb8eb26d
commit 0ae2903035
3 changed files with 15 additions and 7 deletions

View File

@@ -70,13 +70,13 @@ class AuthController {
const { error, value } = loginSchema.validate(req.body, { abortEarly: false });
if (error) return res.status(400).json(setResponse([], 'Validation failed', 400));
const { email, password, captcha, captchaText } = value;
const { identifier, password, captcha, captchaText } = value;
if (!captcha || captcha.toLowerCase() !== captchaText.toLowerCase()) {
return res.status(400).json(setResponse([], 'Invalid captcha', 400));
}
const { user, tokens } = await AuthService.login({ email, password });
const { user, tokens } = await AuthService.login({ identifier, password });
// Set refresh token di cookie
res.cookie('refreshToken', tokens.refreshToken, {