fix: close sesion in public page
This commit is contained in:
@@ -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') {
|
||||
|
||||
Reference in New Issue
Block a user