Fixing callout to hcaptcha verify page
All checks were successful
Jenkins Production Deployment

This commit is contained in:
Patrick Müller 2022-01-12 21:32:23 +01:00
parent 924d16a1a4
commit 9c234e6994
Signed by: Paddy
GPG Key ID: 37ABC11275CAABCE
3 changed files with 5 additions and 11 deletions

View File

@ -127,7 +127,8 @@ climbingGymRouter.post('/', async (req: Request, res: Response) => {
} }
// Verify captcha // Verify captcha
if (!await verifyCaptcha(captcha_token)) { let success = await verifyCaptcha(captcha_token);
if (!success) {
res.status(403).send({'message': 'Invalid Captcha. Please try again.'}); res.status(403).send({'message': 'Invalid Captcha. Please try again.'});
return; return;
} }

View File

@ -26,7 +26,7 @@ export const createGym = async (name: string, city: string): Promise<number> =>
try { try {
let res = await conn.query('INSERT INTO climbing_gyms (name, city) VALUES (?, ?) RETURNING gym_id', [name, city]); let res = await conn.query('INSERT INTO climbing_gyms (name, city) VALUES (?, ?) RETURNING gym_id', [name, city]);
return res[0].hall_id; return res[0].gym_id;
} catch (err) { } catch (err) {
throw err; throw err;
} }

View File

@ -10,13 +10,6 @@ export const verifyCaptcha = async (captcha_token: string): Promise<boolean> =>
secret: process.env.HCAPTCHA_SECRET secret: process.env.HCAPTCHA_SECRET
}); });
axios.post('https://hcaptcha.com/siteverify', postData) let res = await axios.post('https://hcaptcha.com/siteverify', postData);
.then(res => { return res.data.success;
return res.data.success;
})
.catch(error => {
throw(error);
});
return false;
}; };