Work on login
This commit is contained in:
@@ -6,6 +6,7 @@ import { i18n, setLocale, initialLocale } from './i18n.js'
|
||||
import './css/all.css'
|
||||
|
||||
import App from './app.vue'
|
||||
import { isLogedIn } from './global.js'
|
||||
|
||||
await setLocale(initialLocale())
|
||||
|
||||
@@ -18,5 +19,12 @@ if (import.meta.hot) {
|
||||
handleHotUpdate(router)
|
||||
}
|
||||
|
||||
router.beforeEach(async (to, from) => {
|
||||
if (!isLogedIn.value && to.name != '/login' ) {
|
||||
// redirect the user to the login page
|
||||
return { name: '/login' }
|
||||
}
|
||||
})
|
||||
|
||||
createApp(App).use(router).use(i18n).mount('#app')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user