change routes to update and create lib
This commit is contained in:
+27
-4
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div>
|
||||
<Header />
|
||||
<h1 class="my-5">Inicia Sesion</h1>
|
||||
<h1 class="my-5">Inicia Sesión</h1>
|
||||
<div class="row d-flex justify-content-center">
|
||||
<div class="col-12 col-md-8 col-lg-6 col-xl-6">
|
||||
<form class="row d-flex justify-content-center">
|
||||
@@ -35,7 +35,9 @@
|
||||
|
||||
<script>
|
||||
import Header from "./../components/header.vue";
|
||||
|
||||
import axios from "axios";
|
||||
import config from "../config/config.js";
|
||||
import Swal from 'sweetalert2'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@@ -47,12 +49,33 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
login() {
|
||||
alert(this.data.email);
|
||||
const data = {
|
||||
usuario: this.email,
|
||||
password: this.password
|
||||
}
|
||||
axios.post( `${config.api}/loginAdmin`, data ).then(async response =>{
|
||||
localStorage.setItem('tokenPortal', response.data.token);
|
||||
localStorage.setItem('userNamePortal', response.data.user);
|
||||
await Swal.fire(
|
||||
'Bienvenido',
|
||||
'',
|
||||
'success'
|
||||
);
|
||||
this.$router.replace('/portalAdmin');
|
||||
|
||||
}).catch(() =>{
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'El usuario o la contraseña es incorrecta',
|
||||
text: `Intentalo de nuevo.`,
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
components: {
|
||||
Header
|
||||
}
|
||||
},
|
||||
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user