This commit is contained in:
Mawoka
2022-05-02 16:18:27 +02:00
parent 4ac93b3624
commit 92b24d5a3e
6 changed files with 66 additions and 41 deletions
+15 -10
View File
@@ -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,
+11 -6
View File
@@ -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()}`);
+10 -6
View File
@@ -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');
}