From 59fe03f3d23dc2816b70c0873c40159b5ff24f1f Mon Sep 17 00:00:00 2001 From: HF Date: Mon, 18 May 2020 09:46:22 +0200 Subject: [PATCH] add hCaptcha test button --- public/hcaptcha.svg | 82 +++++++++++++++++++++++++++++++++++++ src/client.js | 10 +++-- src/components/UserArea.jsx | 19 +++++++++ 3 files changed, 107 insertions(+), 4 deletions(-) create mode 100644 public/hcaptcha.svg diff --git a/public/hcaptcha.svg b/public/hcaptcha.svg new file mode 100644 index 00000000..fb514f2e --- /dev/null +++ b/public/hcaptcha.svg @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/client.js b/src/client.js index 913c4d94..11c1dd69 100644 --- a/src/client.js +++ b/src/client.js @@ -135,10 +135,12 @@ window.onCaptcha = async function onCaptcha(token: string) { credentials: 'include', }); - const { - i, j, offset, color, - } = window.pixel; - store.dispatch(tryPlacePixel(i, j, offset, color)); + if (window.pixel) { + const { + i, j, offset, color, + } = window.pixel; + store.dispatch(tryPlacePixel(i, j, offset, color)); + } if (typeof window.hcaptcha !== 'undefined') { window.hcaptcha.reset(); diff --git a/src/components/UserArea.jsx b/src/components/UserArea.jsx index d70e8573..26c9f9f9 100644 --- a/src/components/UserArea.jsx +++ b/src/components/UserArea.jsx @@ -156,6 +156,25 @@ class UserArea extends React.Component { done={() => { this.setState({ deleteAccountExtended: false }); }} /> )} + {(typeof window.hcaptcha !== 'undefined') + && ( + hCaptcha { + window.pixel = null; + window.hcaptcha.execute(); + }} + style={{ + width: '5%', + height: '5%', + paddingTop: 20, + cursor: 'pointer', + }} + /> + )}

); }