Commit 47490d0a authored by Adrian's avatar Adrian

Sessiones

parent a70944f5
......@@ -81,8 +81,8 @@ export default {
cleanData(store) {
store.commit('setDefault');
},
async logout(router) {
const storevuex = this.$store;
async logout(router, store) {
const storevuex = store || this.$store;
router = router || this.$router;
this.$storage.removeUser();
this.$storage.remove('theme');
......@@ -94,8 +94,10 @@ export default {
this.$storage.remove('template');
this.$storage.remove('error');
this.$storage.remove('sidenav');
this.cleanData(storevuex);
if (this.$route.path !== '/login') {
const { path } = router && router.history ? router.history.current : null;
if (path !== '/login') {
router.push('/login');
}
}
......
import axios from 'axios';
import Auth from '@/components/auth/mixins/auth';
import store from '@/store';
import router from '@/router';
import Store from '@/store';
const protocol = window.location.protocol.replace(':', '');
const PATERN_HOST = protocol === 'https' ? /(https:\/\/|www\.)\S+/i : /(http:\/\/|www\.)\S+/i;
export default {
store,
Store,
router,
install: (Vue, config) => {
// Config
......@@ -201,7 +201,7 @@ export default {
if (error.response.status === 401) {
if (window.location.hash !== '#/login') {
Message.error('Termino la session');
instance.logout(router, store);
instance.logout(router, Store);
}
}
if (error.response.status === 402) {
......@@ -209,7 +209,7 @@ export default {
Message.error(message);
}
if (error.response.status === 403) {
store.commit('setState403', true);
Store.commit('setState403', true);
router.push('/404');
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment