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

@@ -417,7 +417,7 @@
</div>
<div class="form-section">
<div class="mb-4 mt-3">
<label class="custom-label">Terminos</label>
<label class="custom-label">Productos</label>
<Products
v-model="formLoad.terms"
/>

View File

@@ -155,8 +155,8 @@ const router = createRouter({
router.beforeEach( async(to, from, next) => {
const requiresAuth = to.matched.some(url => url.meta.requiresAuth)
if(requiresAuth === true) {
const session = localStorage.getItem('session');
if(requiresAuth) {
//Comprobamos si el usuario esta authenticado
if(session) {
// if(!authStore.user) {

View File

@@ -64,7 +64,7 @@ export const getCompanies = async(filter) => {
export const getLoadPublic = async(id) => {
try {
const endpoint = `/v1/public-load-tracking/${id}`;
console.log(endpoint);
// console.log(endpoint);
const {data} = await api.get(endpoint);
return data;
} catch (error) {

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') {