change routes to update and create lib

This commit is contained in:
2021-01-11 03:19:47 -06:00
parent 30d93847a5
commit 2e8938f863
16 changed files with 176 additions and 148 deletions
+27 -4
View File
@@ -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>