Login para admin
This commit is contained in:
@@ -13,11 +13,7 @@
|
||||
/>
|
||||
</b-field>
|
||||
|
||||
<!-- <b-field label="Carrera" :type="error">
|
||||
<b-input type="text" @keyup.enter.native="login()" v-model="carrera" />
|
||||
</b-field> -->
|
||||
|
||||
<b-field label="NIP" :type="error">
|
||||
<b-field label="Contraseña" :type="error">
|
||||
<b-input
|
||||
type="password"
|
||||
@keyup.enter.native="login()"
|
||||
@@ -60,9 +56,8 @@ export default {
|
||||
methods: {
|
||||
login() {
|
||||
if (this.numeroCuenta && this.password && !this.error) {
|
||||
console.log(typeof this.numeroCuenta)
|
||||
const data = {
|
||||
usuario: 'votacionesUser',
|
||||
password: 'poasfnr*/049_]',
|
||||
numeroCuenta: this.numeroCuenta,
|
||||
passwordUser: this.password,
|
||||
}
|
||||
@@ -71,6 +66,7 @@ export default {
|
||||
axios
|
||||
.post(`${process.env.api}/usuario/login`, data)
|
||||
.then((res) => {
|
||||
console.log(res)
|
||||
const info = res.data
|
||||
localStorage.setItem('datosUsuario', JSON.stringify(info))
|
||||
// localStorage.setItem('token', info.token)
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
<template>
|
||||
<div class="full-h is-flex is-justify-content-center is-align-items-center">
|
||||
<form class="box">
|
||||
<div class="has-text-centered">
|
||||
<h2 class="is-size-1">CEDETEC</h2>
|
||||
</div>
|
||||
|
||||
<b-field label="Usuario" :type="error">
|
||||
<b-input type="text" @keyup.enter.native="login()" v-model="usuario" />
|
||||
</b-field>
|
||||
|
||||
<b-field label="Contraseña" :type="error">
|
||||
<b-input
|
||||
type="password"
|
||||
@keyup.enter.native="login()"
|
||||
v-model="password"
|
||||
password-reveal
|
||||
/>
|
||||
</b-field>
|
||||
|
||||
<div class="has-text-centered">
|
||||
<b-button
|
||||
@click="login()"
|
||||
type="is-success"
|
||||
:disabled="error || !(usuario && password)"
|
||||
>
|
||||
Iniciar Sesión
|
||||
</b-button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from 'axios'
|
||||
|
||||
export default {
|
||||
props: {
|
||||
imprimirMensaje: { type: Function, required: true },
|
||||
imprimirWarning: { type: Function, required: true },
|
||||
imprimirError: { type: Function, required: true },
|
||||
updateIsLoading: { type: Function, required: true },
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
usuario: '',
|
||||
password: '',
|
||||
error: '',
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
login() {
|
||||
if (this.usuario && this.password && !this.error) {
|
||||
console.log(typeof this.usuario)
|
||||
const data = {
|
||||
usuario: this.usuario,
|
||||
password: this.password,
|
||||
}
|
||||
|
||||
this.updateIsLoading(true)
|
||||
axios
|
||||
.post(`${process.env.api}/admin/login`, data)
|
||||
.then((res) => {
|
||||
const info = res.data
|
||||
// localStorage.setItem('token', info.token)
|
||||
this.updateIsLoading(false)
|
||||
this.$router.push(`/${'admin'}`)
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
this.error = 'is-danger'
|
||||
this.updateIsLoading(false)
|
||||
this.imprimirError(err.response.data)
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
password() {
|
||||
if (this.error) this.error = ''
|
||||
},
|
||||
usuario() {
|
||||
if (this.error) this.error = ''
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.full-h {
|
||||
height: 75vh;
|
||||
}
|
||||
|
||||
form {
|
||||
width: 30rem;
|
||||
}
|
||||
</style>
|
||||
+21
-4
@@ -1,28 +1,45 @@
|
||||
<template>
|
||||
<section class="container">
|
||||
<Login
|
||||
<LoginUser
|
||||
v-if="type === 'User'"
|
||||
:imprimirMensaje="imprimirMensaje"
|
||||
:imprimirWarning="imprimirWarning"
|
||||
:imprimirError="imprimirError"
|
||||
:updateIsLoading="updateIsLoading"
|
||||
/>
|
||||
|
||||
<LoginAdmin
|
||||
v-if="type === 'Admin'"
|
||||
:imprimirMensaje="imprimirMensaje"
|
||||
:imprimirWarning="imprimirWarning"
|
||||
:imprimirError="imprimirError"
|
||||
:updateIsLoading="updateIsLoading"
|
||||
/>
|
||||
|
||||
<div class="has-text-centered">
|
||||
<b-button @click="types()">{{ type }}</b-button>
|
||||
</div>
|
||||
|
||||
<b-loading :is-full-page="true" v-model="isLoading" :can-cancel="false" />
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Login from '@/components/Login'
|
||||
import LoginUser from '@/components/Login'
|
||||
import LoginAdmin from '@/components/admin/login'
|
||||
|
||||
export default {
|
||||
components: { Login },
|
||||
components: { LoginUser, LoginAdmin },
|
||||
data() {
|
||||
return {
|
||||
// admin: '',
|
||||
isLoading: false,
|
||||
type: 'User',
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
types() {
|
||||
this.type == 'Admin' ? (this.type = 'User') : (this.type = 'Admin')
|
||||
},
|
||||
updateIsLoading(booleanValue) {
|
||||
this.isLoading = booleanValue
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user