I want to add google recaptcha 3 in my vuetify project
The google recaptcha 3 like this :
I get reference from here : https://www.npmjs.com/package/vue-recaptcha-v3
First : I run npm install vue-recaptcha-v3
Second : I modify my main.js like this :
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import './registerServiceWorker'
import vuetify from './plugins/vuetify'
import { VueReCaptcha } from 'vue-recaptcha-v3'
Vue.config.productionTip = false
Vue.use(VueReCaptcha, {
siteKey: '<site key>',
loaderOptions: {
useRecaptchaNet: true
}
})
new Vue({
router,
store,
vuetify,
render: h => h(App),
methods: {
recaptcha() {
this.$recaptcha('login').then((token) => {
console.log(token) // Will print the token
})
}
},
template: '<button @click="recaptcha">Execute recaptcha</button>'
}).$mount('#app')
My problem is i am confused to call it from my component
My vue component like this :
<template>
<v-container>
...
<v-row>
<v-col
cols="6"
>
<v-form v-model="valid" ref="form"
>
<v-text-field
label="Full Name"
outlined
v-model="fullname"
></v-text-field>
<v-text-field
label="Email"
outlined
v-model="email"
></v-text-field>
<v-text-field
label="Phone"
outlined
v-model="phone"
></v-text-field>
<v-row justify="center">
<v-btn color="green accent-4" :dark="valid" @click="validate()" :disabled="!valid">Save
<v-icon dark right>mdi-checkbox-marked-circle</v-icon>
</v-btn>
</v-row>
</v-form>
</v-col>
</v-row>
...
</v-container>
</template>
<script>
export default {
data: () => ({
})
}
</script>
How can I call google recaptcha 3 from my component?
You get two token from admin console when a site is added.
Use client secret in the Vue application and the server secret in the backend
Add recaptcha on any events
It returns the login token, you can use this to send post request to recaptcha to verify the user