[bug] fix validating captcha

This commit is contained in:
Avris 2021-08-09 22:58:42 +02:00
parent ab36683ab8
commit 0b1bddfb09
1 changed files with 4 additions and 4 deletions

View File

@ -306,10 +306,6 @@ router.post('/user/change-email', handleErrorAsync(async (req, res) => {
return res.status(401).json({error: 'Unauthorised'}); return res.status(401).json({error: 'Unauthorised'});
} }
if (!await validateCaptcha(req.body.captchaToken)) {
return res.json({error: 'captcha.invalid'});
}
if (!await validateEmail(req.user.email)) { if (!await validateEmail(req.user.email)) {
return res.json({ error: 'user.account.changeEmail.invalid' }) return res.json({ error: 'user.account.changeEmail.invalid' })
} }
@ -320,6 +316,10 @@ router.post('/user/change-email', handleErrorAsync(async (req, res) => {
} }
if (!req.body.authId) { if (!req.body.authId) {
if (!await validateCaptcha(req.body.captchaToken)) {
return res.json({error: 'captcha.invalid'});
}
const payload = { const payload = {
from: req.user.email, from: req.user.email,
to: normalise(req.body.email), to: normalise(req.body.email),