Changeset View
Changeset View
Standalone View
Standalone View
src/resources/vue/App.vue
<template> | <template> | ||||
<router-view v-if="!isLoading && !routerReloading" :key="key" @hook:mounted="childMounted"></router-view> | <router-view v-if="!isLoading && !routerReloading && key" :key="key" @hook:mounted="childMounted"></router-view> | ||||
</template> | </template> | ||||
<script> | <script> | ||||
export default { | export default { | ||||
data() { | data() { | ||||
return { | return { | ||||
isLoading: true, | isLoading: true, | ||||
routerReloading: false | routerReloading: false | ||||
} | } | ||||
}, | }, | ||||
computed: { | computed: { | ||||
key() { | key() { | ||||
// Display 403 error page if the current user has no permission to a specified page | |||||
// Note that it's the only place I found that allows us to do this. | |||||
if (this.$route.meta.perm && !this.checkPermission(this.$route.meta.perm)) { | |||||
// Returning false here will block the page component from execution, | |||||
// as we're using the key in v-if condition on the router-view above | |||||
return false | |||||
} | |||||
// The 'key' property is used to reload the Page component | // The 'key' property is used to reload the Page component | ||||
// whenever a route changes. Normally vue does not do that. | // whenever a route changes. Normally vue does not do that. | ||||
return this.$route.name == '404' ? this.$route.path : 'static' | return this.$route.name == '404' ? this.$route.path : 'static' | ||||
} | } | ||||
}, | }, | ||||
mounted() { | mounted() { | ||||
const token = localStorage.getItem('token') | const token = localStorage.getItem('token') | ||||
Show All 13 Lines | export default { | ||||
this.$root.logoutUser(false) | this.$root.logoutUser(false) | ||||
this.$root.errorHandler(error) | this.$root.errorHandler(error) | ||||
}) | }) | ||||
} else { | } else { | ||||
this.isLoading = false | this.isLoading = false | ||||
} | } | ||||
}, | }, | ||||
methods: { | methods: { | ||||
checkPermission(type) { | |||||
if (this.$root.hasPermission(type)) { | |||||
return true | |||||
} | |||||
const hint = type == 'wallets' ? "Only account owners can access a wallet." : '' | |||||
this.$root.errorPage(403, null, hint) | |||||
return false | |||||
}, | |||||
childMounted() { | childMounted() { | ||||
this.$root.updateBodyClass() | this.$root.updateBodyClass() | ||||
this.getFAQ() | this.getFAQ() | ||||
}, | }, | ||||
getFAQ() { | getFAQ() { | ||||
let page = this.$route.path | let page = this.$route.path | ||||
if (page == '/' || page == '/login') { | if (page == '/' || page == '/login') { | ||||
Show All 40 Lines |