diff --git a/src/client/components/captcha.vue b/src/client/components/captcha.vue new file mode 100644 index 000000000..6b1ee6f0b --- /dev/null +++ b/src/client/components/captcha.vue @@ -0,0 +1,119 @@ + + + {{ $t('waiting') }} + + + + + diff --git a/src/client/components/hcaptcha.vue b/src/client/components/hcaptcha.vue deleted file mode 100644 index 4bc03342f..000000000 --- a/src/client/components/hcaptcha.vue +++ /dev/null @@ -1,77 +0,0 @@ - - - - - diff --git a/src/client/components/signup-dialog.vue b/src/client/components/signup-dialog.vue index 10cdf3a56..4db79af51 100644 --- a/src/client/components/signup-dialog.vue +++ b/src/client/components/signup-dialog.vue @@ -1,5 +1,5 @@ - { $emit('closed'); destroyDom(); }"> + { $emit('closed'); destroyDom(); }"> {{ $t('signup') }} diff --git a/src/client/components/signup.vue b/src/client/components/signup.vue index 5d16a82ba..7e8bac776 100644 --- a/src/client/components/signup.vue +++ b/src/client/components/signup.vue @@ -41,8 +41,8 @@ {{ $t('tos') }} - - + + {{ $t('start') }} @@ -66,7 +66,7 @@ export default Vue.extend({ MkButton, MkInput, MkSwitch, - hCaptcha: () => import('./hcaptcha.vue').then(x => x.default), + captcha: () => import('./captcha.vue').then(x => x.default), }, data() { @@ -83,6 +83,7 @@ export default Vue.extend({ submitting: false, ToSAgreement: false, hCaptchaResponse: null, + reCaptchaResponse: null, faLock, faExclamationTriangle, faSpinner, faCheck, faKey } }, @@ -124,14 +125,6 @@ export default Vue.extend({ } }, - mounted() { - if (this.meta.enableRecaptcha) { - const script = document.createElement('script'); - script.setAttribute('src', 'https://www.google.com/recaptcha/api.js'); - document.head.appendChild(script); - } - }, - methods: { onChangeUsername() { if (this.username == '') { @@ -189,7 +182,7 @@ export default Vue.extend({ password: this.password, invitationCode: this.invitationCode, 'hcaptcha-response': this.hCaptchaResponse, - 'g-recaptcha-response': this.meta.enableRecaptcha ? (window as any).grecaptcha.getResponse() : null + 'g-recaptcha-response': this.meta.reCaptchaResponse, }).then(() => { this.$root.api('signin', { username: this.username, @@ -199,17 +192,25 @@ export default Vue.extend({ }); }).catch(() => { this.submitting = false; + this.$refs.hcaptcha?.reset?.(); + this.$refs.recaptcha?.reset?.(); this.$root.dialog({ type: 'error', text: this.$t('error') }); - - if (this.meta.enableRecaptcha) { - (window as any).grecaptcha.reset(); - } }); } } }); + + diff --git a/src/client/pages/instance/settings.vue b/src/client/pages/instance/settings.vue index 008d6ef1a..f0fa84699 100644 --- a/src/client/pages/instance/settings.vue +++ b/src/client/pages/instance/settings.vue @@ -41,15 +41,15 @@ {{ $t('hcaptcha') }} - {{ $t('enableHcaptcha') }} + {{ $t('enableHcaptcha') }} {{ $t('hcaptchaSiteKey') }} {{ $t('hcaptchaSecretKey') }} - + {{ $t('preview') }} - +