mirror of
https://github.com/movie-web/backend.git
synced 2025-09-13 18:13:26 +00:00
update deprecated composer syntax; change body format in API request
This commit is contained in:
@@ -4,16 +4,14 @@ import { StatusError } from '@/services/error';
|
||||
export async function isValidCaptcha(token: string): Promise<boolean> {
|
||||
if (!conf.captcha.secret)
|
||||
throw new Error('isValidCaptcha() is called but no secret set');
|
||||
const formData = new URLSearchParams();
|
||||
formData.append('secret', conf.captcha.secret);
|
||||
formData.append('response', token);
|
||||
const res = await fetch('https://www.google.com/recaptcha/api/siteverify', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
secret: conf.captcha.secret,
|
||||
response: token,
|
||||
}),
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
},
|
||||
body: formData,
|
||||
});
|
||||
|
||||
const json = await res.json();
|
||||
return !!json.success;
|
||||
}
|
||||
|
Reference in New Issue
Block a user