Skip to content

Commit

Permalink
fix recaptcha loading
Browse files Browse the repository at this point in the history
  • Loading branch information
zlayine committed Apr 19, 2024
1 parent 92e4068 commit 16acc0f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
8 changes: 7 additions & 1 deletion resources/js/components/pages/auth/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@
Forgot your password?
</RouterLink>
</div>
<Btn is-submit primary :loading="isLoading" class="w-full"> Sign in </Btn>
<Btn is-submit primary :disabled="!isCaptchaBadgeVisible" :loading="isLoading" class="w-full">
Sign in
</Btn>
</div>
</Form>
</div>
Expand Down Expand Up @@ -112,6 +114,8 @@ const onCaptchaExpired = () => {
const loadCaptchaScript = async () => {
if (!hasCaptcha) {
isCaptchaBadgeVisible.value = true;
return;
}
if (!document.getElementById('recaptcha-script')) {
Expand Down Expand Up @@ -214,6 +218,8 @@ const resendVerification = async () => {
checkVerified();
if (appStore.loggedIn) {
redirectToCollections();
} else {
loadCaptchaScript();
}
})();
Expand Down
12 changes: 10 additions & 2 deletions resources/js/components/pages/auth/Register.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@
</RouterLink>
</div>
</div>
<Btn is-submit primary :loading="isLoading" class="w-full"> Register </Btn>
<Btn is-submit primary :disabled="!isCaptchaBadgeVisible" :loading="isLoading" class="w-full">
Register
</Btn>
</div>
</Form>
</div>
Expand Down Expand Up @@ -114,7 +116,11 @@ const onCaptchaExpired = () => {
};
const loadCaptchaScript = async () => {
if (!hasCaptcha) return;
if (!hasCaptcha) {
isCaptchaBadgeVisible.value = true;
return;
}
if (!document.getElementById('recaptcha-script')) {
const script = document.createElement('script');
Expand Down Expand Up @@ -165,6 +171,8 @@ const register = async (recaptcha?: string) => {
(async () => {
if (appStore.loggedIn) {
redirectToLogin();
} else {
loadCaptchaScript();
}
})();
</script>
8 changes: 7 additions & 1 deletion resources/js/components/pages/auth/RequestResetPassword.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
</RouterLink>
</div>
</div>
<Btn is-submit primary :loading="isLoading" class="w-full"> Reset Password </Btn>
<Btn is-submit primary :disabled="!isCaptchaBadgeVisible" :loading="isLoading" class="w-full">
Reset Password
</Btn>
</div>
</Form>
</div>
Expand Down Expand Up @@ -94,6 +96,8 @@ const onCaptchaExpired = () => {
const loadCaptchaScript = async () => {
if (!hasCaptcha) {
isCaptchaBadgeVisible.value = true;
return;
}
if (!document.getElementById('recaptcha-script')) {
Expand Down Expand Up @@ -136,6 +140,8 @@ const requestReset = async (recaptcha?: string) => {
(async () => {
if (appStore.loggedIn) {
redirectToCollections();
} else {
loadCaptchaScript();
}
})();
</script>

0 comments on commit 16acc0f

Please sign in to comment.