fix: close sesion in public page

This commit is contained in:
Alexandro Uc Santos
2024-04-19 20:19:25 -06:00
parent ada429b7bf
commit 18920ac2fc
4 changed files with 19 additions and 7 deletions

View File

@@ -1,6 +1,6 @@
import { defineStore } from "pinia";
import { ref, onMounted } from "vue";
import { useRouter } from 'vue-router';
import { useRoute, useRouter } from 'vue-router';
import { renewToken } from '../services/auth';
import {useNotificationsStore} from './notifications';
import {useCompanyStore} from './company';
@@ -11,6 +11,7 @@ import { updateMyUserProfile } from "../services/company";
export const useAuthStore = defineStore('auth', () => {
const router = useRouter();
const route = useRoute();
const noty = useNotificationsStore();
const company = useCompanyStore();
const loadStore = useLoadsStore();
@@ -19,16 +20,27 @@ export const useAuthStore = defineStore('auth', () => {
const checking = ref(false);
const authStatus = ref('checking');
const token = ref('')
const user = ref(null)
const user = ref(null);
const publicNames = [
'terms-conditions',
'notice-privacy',
'tracking-load',
'faqs',
'login',
'register',
'recovery',
'register-company',
]
onMounted( async() => {
checkSession();
});
const checkSession = async() => {
const session = localStorage.getItem('session');
authStatus.value = 'checking';
if(session) {
if(session && !publicNames.includes(route.name)) {
checking.value = true;
const resp = await renewToken();
if(resp.msg === 'success') {