Added v-model support - #53
Open
salomaosnff wants to merge 2 commits into
Open
Conversation
DSergiu
reviewed
Jan 20, 2022
| const token = this.hcaptcha.getResponse(this.widgetId); | ||
| const eKey = this.hcaptcha.getRespKey(this.widgetId); | ||
| this.$emit('verify', token, eKey); | ||
| this.$emit('input', token); |
Contributor
There was a problem hiding this comment.
v-model would allow 2way binding which I believe would not make sense for the component.
One solution could be to listen to the verify and expire events and bind the token to a local data in your parent component. e.g.
<h-captcha
...
@verify="(token) => {hCaptchaToken = token}"
@expire="hCaptchaToken =null"
/>
// use hCaptchaToken for "required" in "vee-validate"
Author
There was a problem hiding this comment.
Although the component doesn't accept the token as input, I think using v-model would make it simpler to use. Another alternative that would solve the same problem would be to use token.sync instead of v-model. Thus, it would not be necessary to create event-listeners and callbacks in the component call
DSergiu
reviewed
Jan 20, 2022
| onChallengeExpired() { | ||
| // vue3 will transform this `camelCase` event name into `kebab-case` | ||
| this.$emit('challengeExpired'); | ||
| this.$emit('input', null); |
Contributor
There was a problem hiding this comment.
When a challenge expires the token status does not change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Now it is possible to get the token using
v-modeland also validate it with vee-validate with therequiredrule for example.