update deprecated composer syntax; change body format in API request
This commit is contained in:
parent
9a27b0b0b4
commit
0c3de831fb
|
@ -41,7 +41,7 @@ services:
|
||||||
links:
|
links:
|
||||||
- postgres:postgres
|
- postgres:postgres
|
||||||
environment:
|
environment:
|
||||||
- DATABASE_URL=postgres://postgres:postgres@postgres:5432/postgres?sslmode=disable
|
- PGWEB_DATABASE_URL=postgres://postgres:postgres@postgres:5432/postgres?sslmode=disable
|
||||||
depends_on:
|
depends_on:
|
||||||
- postgres
|
- postgres
|
||||||
|
|
||||||
|
|
|
@ -4,16 +4,14 @@ import { StatusError } from '@/services/error';
|
||||||
export async function isValidCaptcha(token: string): Promise<boolean> {
|
export async function isValidCaptcha(token: string): Promise<boolean> {
|
||||||
if (!conf.captcha.secret)
|
if (!conf.captcha.secret)
|
||||||
throw new Error('isValidCaptcha() is called but no secret set');
|
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', {
|
const res = await fetch('https://www.google.com/recaptcha/api/siteverify', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({
|
body: formData,
|
||||||
secret: conf.captcha.secret,
|
|
||||||
response: token,
|
|
||||||
}),
|
|
||||||
headers: {
|
|
||||||
'content-type': 'application/json',
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const json = await res.json();
|
const json = await res.json();
|
||||||
return !!json.success;
|
return !!json.success;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue