fix: Reset Captcha if account signup is an error (#4279)
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
parent
3cd1616df6
commit
cb23ff53bf
3 changed files with 36 additions and 1 deletions
|
@ -23,7 +23,7 @@ export default {
|
||||||
background: var(--s-500);
|
background: var(--s-500);
|
||||||
}
|
}
|
||||||
&__busy {
|
&__busy {
|
||||||
background: var(--y-700);
|
background: var(--y-400);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -15,6 +15,9 @@
|
||||||
"SUCCESS_MESSAGE": "Successfully changed the password",
|
"SUCCESS_MESSAGE": "Successfully changed the password",
|
||||||
"ERROR_MESSAGE": "Could not connect to Woot Server, Please try again later"
|
"ERROR_MESSAGE": "Could not connect to Woot Server, Please try again later"
|
||||||
},
|
},
|
||||||
|
"CAPTCHA": {
|
||||||
|
"ERROR": "Verification expired. Please solve captcha again."
|
||||||
|
},
|
||||||
"SUBMIT": "Submit"
|
"SUBMIT": "Submit"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,9 +77,17 @@
|
||||||
/>
|
/>
|
||||||
<div v-if="globalConfig.hCaptchaSiteKey" class="h-captcha--box">
|
<div v-if="globalConfig.hCaptchaSiteKey" class="h-captcha--box">
|
||||||
<vue-hcaptcha
|
<vue-hcaptcha
|
||||||
|
ref="hCaptcha"
|
||||||
|
:class="{ error: !hasAValidCaptcha && didCaptchaReset }"
|
||||||
:sitekey="globalConfig.hCaptchaSiteKey"
|
:sitekey="globalConfig.hCaptchaSiteKey"
|
||||||
@verify="onRecaptchaVerified"
|
@verify="onRecaptchaVerified"
|
||||||
/>
|
/>
|
||||||
|
<span
|
||||||
|
v-if="!hasAValidCaptcha && didCaptchaReset"
|
||||||
|
class="captcha-error"
|
||||||
|
>
|
||||||
|
{{ $t('SET_NEW_PASSWORD.CAPTCHA.ERROR') }}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<woot-submit-button
|
<woot-submit-button
|
||||||
:disabled="isSignupInProgress || !hasAValidCaptcha"
|
:disabled="isSignupInProgress || !hasAValidCaptcha"
|
||||||
|
@ -129,6 +137,7 @@ export default {
|
||||||
confirmPassword: '',
|
confirmPassword: '',
|
||||||
hCaptchaClientResponse: '',
|
hCaptchaClientResponse: '',
|
||||||
},
|
},
|
||||||
|
didCaptchaReset: false,
|
||||||
isSignupInProgress: false,
|
isSignupInProgress: false,
|
||||||
error: '',
|
error: '',
|
||||||
};
|
};
|
||||||
|
@ -183,6 +192,7 @@ export default {
|
||||||
async submit() {
|
async submit() {
|
||||||
this.$v.$touch();
|
this.$v.$touch();
|
||||||
if (this.$v.$invalid) {
|
if (this.$v.$invalid) {
|
||||||
|
this.resetCaptcha();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.isSignupInProgress = true;
|
this.isSignupInProgress = true;
|
||||||
|
@ -194,6 +204,7 @@ export default {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
let errorMessage = this.$t('REGISTER.API.ERROR_MESSAGE');
|
let errorMessage = this.$t('REGISTER.API.ERROR_MESSAGE');
|
||||||
if (error.response && error.response.data.message) {
|
if (error.response && error.response.data.message) {
|
||||||
|
this.resetCaptcha();
|
||||||
errorMessage = error.response.data.message;
|
errorMessage = error.response.data.message;
|
||||||
}
|
}
|
||||||
this.showAlert(errorMessage);
|
this.showAlert(errorMessage);
|
||||||
|
@ -203,6 +214,15 @@ export default {
|
||||||
},
|
},
|
||||||
onRecaptchaVerified(token) {
|
onRecaptchaVerified(token) {
|
||||||
this.credentials.hCaptchaClientResponse = token;
|
this.credentials.hCaptchaClientResponse = token;
|
||||||
|
this.didCaptchaReset = false;
|
||||||
|
},
|
||||||
|
resetCaptcha() {
|
||||||
|
if (!this.globalConfig.hCaptchaSiteKey) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$refs.hCaptcha.reset();
|
||||||
|
this.credentials.hCaptchaClientResponse = '';
|
||||||
|
this.didCaptchaReset = true;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -254,6 +274,18 @@ export default {
|
||||||
|
|
||||||
.h-captcha--box {
|
.h-captcha--box {
|
||||||
margin-bottom: var(--space-one);
|
margin-bottom: var(--space-one);
|
||||||
|
|
||||||
|
.captcha-error {
|
||||||
|
color: var(--r-400);
|
||||||
|
font-size: var(--font-size-small);
|
||||||
|
}
|
||||||
|
|
||||||
|
&::v-deep .error {
|
||||||
|
iframe {
|
||||||
|
border: 1px solid var(--r-500);
|
||||||
|
border-radius: var(--border-radius-normal);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue