update: auth login with username or email
This commit is contained in:
@@ -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, {
|
||||
|
||||
Reference in New Issue
Block a user