no change url with buttons back and forward
This commit is contained in:
@@ -38,12 +38,20 @@ const router = createRouter({
|
||||
]
|
||||
})
|
||||
|
||||
router.beforeEach((to) => {
|
||||
router.beforeEach((to, from) => {
|
||||
// ✅ This will work because the router starts its navigation after
|
||||
// the router is installed and pinia will be installed too
|
||||
const storeUser = useUserStore()
|
||||
console.log(storeUser.isValid)
|
||||
if (to.meta.requiresAuth && !storeUser.isValid) return '/'
|
||||
if (to.meta.requiresAuth && !storeUser.isValid) {
|
||||
if (from.fullPath == '/') {
|
||||
return false
|
||||
}
|
||||
return '/'
|
||||
}
|
||||
if (to.fullPath == '/') {
|
||||
storeUser.user = ''
|
||||
storeUser.isValid = false
|
||||
}
|
||||
})
|
||||
|
||||
export default router
|
||||
|
||||
@@ -3,7 +3,7 @@ import { defineStore } from 'pinia'
|
||||
|
||||
export const useUserStore = defineStore('user', () => {
|
||||
const user = ref()
|
||||
const isValid = ref()
|
||||
const isValid = ref(false)
|
||||
|
||||
return { user, isValid }
|
||||
})
|
||||
@@ -142,9 +142,6 @@ const visibleModalSended = ref(false);
|
||||
const visibleModalInvalid = ref(false);
|
||||
|
||||
onMounted(() => {
|
||||
if (pb != null) {
|
||||
pb.authStore.clear();
|
||||
}
|
||||
pb = new PocketBase("http://127.0.0.1:8090");
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user