This commit is contained in:
@@ -33,29 +33,29 @@ export default defineRouter(function (/* { store, ssrContext } */) {
|
||||
history: createHistory(process.env.VUE_ROUTER_BASE)
|
||||
})
|
||||
|
||||
const publicPath = ['404', 'terms', 'privacy', 'consent']
|
||||
|
||||
Router.beforeEach(async (to) => {
|
||||
if (to.name !== 'telegram_only' && sessionStorage.getItem('isTelegram') === 'false') {
|
||||
return { name: 'telegram_only', replace: true }
|
||||
}
|
||||
|
||||
if (to.name === 'telegram_only') return true
|
||||
|
||||
const authStore = useAuthStore()
|
||||
const projectsStore = useProjectsStore()
|
||||
|
||||
if (to.name === '404' || to.name === 'terms' || to.name === 'privacy' || to.name === 'consent') return true
|
||||
if (to.name === 'login')
|
||||
return authStore.isAuth ? { name: 'projects', replace: true } : true
|
||||
|
||||
if (to.name === 'login') return true
|
||||
if (typeof to.name === 'string' && publicPath.includes(to.name)) return true
|
||||
|
||||
if (to.name === 'agreements' && authStore.isAuth) return true
|
||||
if (to.name === 'agreements') return true
|
||||
|
||||
// if (!authStore.isTermsAccepted && authStore.isAuth) return { name: 'agreements' }
|
||||
|
||||
if (to.meta.guestOnly && authStore.isAuth) {
|
||||
return { name: 'projects' }
|
||||
}
|
||||
|
||||
if (to.meta.requiresAuth && !authStore.isAuth) {
|
||||
return {
|
||||
name: 'login',
|
||||
replace: true
|
||||
}
|
||||
}
|
||||
if (to.name === 'create_account' && !authStore.isAuth) return true
|
||||
|
||||
if (!authStore.isAuth) return { name: 'login', replace: true }
|
||||
|
||||
if (to.params.id) {
|
||||
if (!projectsStore.isInit) await projectsStore.init()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user