listo recaptcha
This commit is contained in:
parent
4a1322745d
commit
b78872bb0d
@ -20,6 +20,10 @@
|
||||
/>
|
||||
</b-field>
|
||||
|
||||
<b-field>
|
||||
<recaptcha />
|
||||
</b-field>
|
||||
|
||||
<div class="has-text-centered">
|
||||
<b-button
|
||||
@click="login()"
|
||||
@ -48,8 +52,16 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
login() {
|
||||
if (this.usuario && this.password && !this.error) {
|
||||
async login() {
|
||||
const token = await this.$recaptcha.getResponse().catch((err) => {
|
||||
this.$alertsGenericos.imprimirError(
|
||||
this.$buefy,
|
||||
this.$router,
|
||||
'Favor de completar el recaptcha'
|
||||
)
|
||||
})
|
||||
|
||||
if (this.usuario && this.password && token && !this.error) {
|
||||
const data = {
|
||||
operador: this.usuario,
|
||||
password: this.password,
|
||||
@ -57,13 +69,16 @@ export default {
|
||||
|
||||
this.updateIsLoading(true)
|
||||
axios
|
||||
.post(`${process.env.api}/auth/login-admin`, data)
|
||||
.then((res) => {
|
||||
.post(`${process.env.api}/auth/login-admin`, data, {
|
||||
headers: { recaptcha: token },
|
||||
})
|
||||
.then(async (res) => {
|
||||
const token = res.data.token
|
||||
const operador = JSON.stringify(res.data.operador)
|
||||
|
||||
localStorage.setItem('operador', operador)
|
||||
localStorage.setItem('token', token)
|
||||
await this.$recaptcha.reset()
|
||||
this.updateIsLoading(false)
|
||||
if (res.data.operador.tipoUsuario.id_tipo_usuario === 2)
|
||||
this.$router.push(
|
||||
@ -91,6 +106,9 @@ export default {
|
||||
if (this.error) this.error = ''
|
||||
},
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.$recaptcha.destroy()
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -42,7 +42,11 @@
|
||||
</b-select>
|
||||
</b-field>
|
||||
|
||||
<div class="has-text-centered">
|
||||
<b-field>
|
||||
<recaptcha />
|
||||
</b-field>
|
||||
|
||||
<b-field class="has-text-centered">
|
||||
<b-button
|
||||
@click="login()"
|
||||
type="is-success"
|
||||
@ -50,16 +54,13 @@
|
||||
>
|
||||
Iniciar Sesión
|
||||
</b-button>
|
||||
</div>
|
||||
|
||||
<recaptcha />
|
||||
</b-field>
|
||||
</form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from 'axios'
|
||||
//import { VueRecaptcha } from 'vue-recaptcha';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
@ -78,22 +79,26 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
async login() {
|
||||
console.log('ReCaptcha token')
|
||||
const token = await this.$recaptcha.getResponse().catch((err) => {
|
||||
console.log(err)
|
||||
this.$alertsGenericos.imprimirError(
|
||||
this.$buefy,
|
||||
this.$router,
|
||||
'Favor de completar el recaptcha'
|
||||
)
|
||||
})
|
||||
console.log('ReCaptcha token:', token)
|
||||
|
||||
if (this.usuario && this.password && token && !this.error) {
|
||||
console.log('hola')
|
||||
const data = {
|
||||
operador: this.usuario,
|
||||
password: this.password,
|
||||
id_modulo: this.idModulo,
|
||||
}
|
||||
|
||||
this.updateIsLoading(true)
|
||||
axios
|
||||
.post(`${process.env.api}/auth/login-operador`, data)
|
||||
.post(`${process.env.api}/auth/login-operador`, data, {
|
||||
headers: { recaptcha: token },
|
||||
})
|
||||
.then(async (res) => {
|
||||
const token = res.data.token
|
||||
const operador = JSON.stringify(res.data.operador)
|
||||
@ -146,20 +151,6 @@ export default {
|
||||
)
|
||||
})
|
||||
},
|
||||
/*
|
||||
async onSubmit() {
|
||||
try {
|
||||
const token = await this.$recaptcha.getResponse()
|
||||
console.log('ReCaptcha token:', token)
|
||||
|
||||
// send token to server alongside your form data
|
||||
|
||||
// at the end you need to reset recaptcha
|
||||
await this.$recaptcha.reset()
|
||||
} catch (error) {
|
||||
console.log('Login error:', error)
|
||||
}
|
||||
}, */
|
||||
},
|
||||
watch: {
|
||||
password() {
|
||||
|
59
package-lock.json
generated
59
package-lock.json
generated
@ -17,8 +17,7 @@
|
||||
"nuxt-buefy": "^0.4.4",
|
||||
"nuxt-socket-io": "^2.0.3",
|
||||
"validator": "^13.6.0",
|
||||
"vue-qrcode-reader": "^3.1.0",
|
||||
"vue-recaptcha": "^2.0.2"
|
||||
"vue-qrcode-reader": "^3.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint-config-prettier": "^8.1.0",
|
||||
@ -13514,31 +13513,6 @@
|
||||
"resolved": "https://registry.npmjs.org/vue-client-only/-/vue-client-only-2.0.0.tgz",
|
||||
"integrity": "sha512-arhk1wtWAfLsJyxGMoEYhoBowM87/i6HLSG2LH/03Yog6i2d9JEN1peMP0Ceis+/n9DxdenGYZZTxbPPJyHciA=="
|
||||
},
|
||||
"node_modules/vue-demi": {
|
||||
"version": "0.12.5",
|
||||
"resolved": "https://registry.npmjs.org/vue-demi/-/vue-demi-0.12.5.tgz",
|
||||
"integrity": "sha512-BREuTgTYlUr0zw0EZn3hnhC3I6gPWv+Kwh4MCih6QcAeaTlaIX0DwOVN0wHej7hSvDPecz4jygy/idsgKfW58Q==",
|
||||
"hasInstallScript": true,
|
||||
"bin": {
|
||||
"vue-demi-fix": "bin/vue-demi-fix.js",
|
||||
"vue-demi-switch": "bin/vue-demi-switch.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/antfu"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@vue/composition-api": "^1.0.0-rc.1",
|
||||
"vue": "^3.0.0-0 || ^2.6.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@vue/composition-api": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/vue-hot-reload-api": {
|
||||
"version": "2.3.4",
|
||||
"resolved": "https://registry.npmjs.org/vue-hot-reload-api/-/vue-hot-reload-api-2.3.4.tgz",
|
||||
@ -13598,23 +13572,6 @@
|
||||
"webrtc-adapter": "7.7.0"
|
||||
}
|
||||
},
|
||||
"node_modules/vue-recaptcha": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/vue-recaptcha/-/vue-recaptcha-2.0.2.tgz",
|
||||
"integrity": "sha512-bE5WMz9jyiiY1PlaBOSUvsgTZ/ONoRV7Oq4Fn4JVz//ul+DJ0LHIJERfoF0NNEIDWXv6GjhwGLveGhoq0sEerg==",
|
||||
"dependencies": {
|
||||
"vue-demi": "^0.12.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@vue/composition-api": "^1.0.0-beta.1",
|
||||
"vue": "^2.0.0 || ^3.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@vue/composition-api": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/vue-router": {
|
||||
"version": "3.5.1",
|
||||
"resolved": "https://registry.npmjs.org/vue-router/-/vue-router-3.5.1.tgz",
|
||||
@ -25673,12 +25630,6 @@
|
||||
"resolved": "https://registry.npmjs.org/vue-client-only/-/vue-client-only-2.0.0.tgz",
|
||||
"integrity": "sha512-arhk1wtWAfLsJyxGMoEYhoBowM87/i6HLSG2LH/03Yog6i2d9JEN1peMP0Ceis+/n9DxdenGYZZTxbPPJyHciA=="
|
||||
},
|
||||
"vue-demi": {
|
||||
"version": "0.12.5",
|
||||
"resolved": "https://registry.npmjs.org/vue-demi/-/vue-demi-0.12.5.tgz",
|
||||
"integrity": "sha512-BREuTgTYlUr0zw0EZn3hnhC3I6gPWv+Kwh4MCih6QcAeaTlaIX0DwOVN0wHej7hSvDPecz4jygy/idsgKfW58Q==",
|
||||
"requires": {}
|
||||
},
|
||||
"vue-hot-reload-api": {
|
||||
"version": "2.3.4",
|
||||
"resolved": "https://registry.npmjs.org/vue-hot-reload-api/-/vue-hot-reload-api-2.3.4.tgz",
|
||||
@ -25728,14 +25679,6 @@
|
||||
"webrtc-adapter": "7.7.0"
|
||||
}
|
||||
},
|
||||
"vue-recaptcha": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/vue-recaptcha/-/vue-recaptcha-2.0.2.tgz",
|
||||
"integrity": "sha512-bE5WMz9jyiiY1PlaBOSUvsgTZ/ONoRV7Oq4Fn4JVz//ul+DJ0LHIJERfoF0NNEIDWXv6GjhwGLveGhoq0sEerg==",
|
||||
"requires": {
|
||||
"vue-demi": "^0.12.1"
|
||||
}
|
||||
},
|
||||
"vue-router": {
|
||||
"version": "3.5.1",
|
||||
"resolved": "https://registry.npmjs.org/vue-router/-/vue-router-3.5.1.tgz",
|
||||
|
@ -18,8 +18,7 @@
|
||||
"nuxt-buefy": "^0.4.4",
|
||||
"nuxt-socket-io": "^2.0.3",
|
||||
"validator": "^13.6.0",
|
||||
"vue-qrcode-reader": "^3.1.0",
|
||||
"vue-recaptcha": "^2.0.2"
|
||||
"vue-qrcode-reader": "^3.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint-config-prettier": "^8.1.0",
|
||||
|
Loading…
Reference in New Issue
Block a user