✨ Fixed #51
This commit is contained in:
@@ -44,17 +44,22 @@
|
||||
return;
|
||||
}
|
||||
let captcha_resp: string;
|
||||
try {
|
||||
const { response } = await hcaptcha.execute(hcaptchaWidgetID, {
|
||||
async: true
|
||||
});
|
||||
captcha_resp = response;
|
||||
} catch (e) {
|
||||
if (import.meta.env.VITE_SENTRY !== null) {
|
||||
Sentry.captureException(e);
|
||||
const captcha_enabled = (
|
||||
await (await fetch(`/api/v1/quiz/play/check_captcha/${game_pin}`)).json()
|
||||
).enabled;
|
||||
if (captcha_enabled) {
|
||||
try {
|
||||
const { response } = await hcaptcha.execute(hcaptchaWidgetID, {
|
||||
async: true
|
||||
});
|
||||
captcha_resp = response;
|
||||
} catch (e) {
|
||||
if (import.meta.env.VITE_SENTRY !== null) {
|
||||
Sentry.captureException(e);
|
||||
}
|
||||
alert('Captcha failed, reloading the page probably helps!');
|
||||
window.location.reload();
|
||||
}
|
||||
alert('Captcha failed, reloading the page probably helps!');
|
||||
window.location.reload();
|
||||
}
|
||||
socket.emit('join_game', {
|
||||
username: username,
|
||||
|
||||
@@ -48,12 +48,17 @@
|
||||
|
||||
const startGame = async (id: string): Promise<void> => {
|
||||
console.log('start game', id);
|
||||
const res = await fetch(`/api/v1/quiz/start/${id}`, {
|
||||
method: 'POST'
|
||||
// headers: {
|
||||
// 'Content-Type': 'application/json'
|
||||
// }
|
||||
});
|
||||
let res;
|
||||
if (window.confirm('Do you want to enable the captcha for players?')) {
|
||||
res = await fetch(`/api/v1/quiz/start/${id}?captcha_enabled=True`, {
|
||||
method: 'POST'
|
||||
});
|
||||
} else {
|
||||
res = await fetch(`/api/v1/quiz/start/${id}?captcha_enabled=False`, {
|
||||
method: 'POST'
|
||||
});
|
||||
}
|
||||
|
||||
if (res.status !== 200) {
|
||||
alert('Failed to start game!');
|
||||
console.error(`Failed to start game, ${await res.text()}`);
|
||||
|
||||
@@ -64,12 +64,16 @@
|
||||
|
||||
const startGame = async (id: string): Promise<void> => {
|
||||
console.log('start game', id);
|
||||
const res = await fetch(`/api/v1/quiz/start/${id}`, {
|
||||
method: 'POST'
|
||||
// headers: {
|
||||
// 'Content-Type': 'application/json'
|
||||
// }
|
||||
});
|
||||
let res;
|
||||
if (window.confirm('Do you want to enable the captcha for players?')) {
|
||||
res = await fetch(`/api/v1/quiz/start/${id}?captcha_enabled=True`, {
|
||||
method: 'POST'
|
||||
});
|
||||
} else {
|
||||
res = await fetch(`/api/v1/quiz/start/${id}?captcha_enabled=False`, {
|
||||
method: 'POST'
|
||||
});
|
||||
}
|
||||
if (res.status !== 200) {
|
||||
throw new Error('Failed to start game');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user