add: guard in router

This commit is contained in:
Alexandro Uc Santos
2024-12-14 17:46:38 -06:00
parent e24f96c061
commit fa56d25258
9 changed files with 148 additions and 37 deletions

View File

@@ -3,9 +3,18 @@
import { useAuthStore } from '../stores/auth';
import Swal from 'sweetalert2';
import { useI18n } from 'vue-i18n';
import { useCompanyStore } from '../stores/company';
import { useVehiclesStore } from '../stores/vehicles';
import { useLoadsStore } from '../stores/loads';
import { useNotificationsStore } from '../stores/notifications';
const route = useRoute();
const auth = useAuthStore();
const company = useCompanyStore();
const vehicles = useVehiclesStore();
const loads = useLoadsStore();
const noty = useNotificationsStore();
const router = useRouter();
const { t } = useI18n()
const handleLogout = () => {
@@ -20,6 +29,11 @@
}).then(async(result) => {
if(result.isConfirmed) {
auth.logout();
company.clear();
vehicles.clear();
loads.clear();
noty.clear();
router.push({name: 'login'});
}
});
}