Cleanup global state logic a bit, for current user and permissions

this still isn't ideal perhaps, but leaves some clues for improvement
This commit is contained in:
Lance Edgar 2019-11-12 11:49:07 -06:00
parent eab0ebcc00
commit 84b2a2bf70
3 changed files with 33 additions and 26 deletions

View file

@ -174,16 +174,24 @@ export default {
mounted() {
// redirect if user doesn't have permission to be here
if ((this.mode == 'creating' && !this.hasModelPerm('create'))
|| (this.mode == 'editing' && !this.hasModelPerm('edit'))) {
this.$buefy.toast.open({
message: "You do not have permission to access that page.",
type: 'is-danger',
position: 'is-bottom',
})
this.$router.push(this.getModelPathPrefix() + '/')
}
// TODO: this seems like a "good" idea, but in practice, when reloading
// the page/app via browser (Ctrl+Shift+R), the app must re-fetch the
// session details before it knows which user/permissions are in
// effect, and that takes "too long" which means these checks fail!
// // redirect if user doesn't have permission to be here
// if ((this.mode == 'viewing' && !this.hasModelPerm('view'))
// || (this.mode == 'creating' && !this.hasModelPerm('create'))
// || (this.mode == 'editing' && !this.hasModelPerm('edit'))
// || (this.mode == 'deleting' && !this.hasModelPerm('delete'))) {
// this.$buefy.toast.open({
// message: "You do not have permission to access that page.",
// type: 'is-danger',
// position: 'is-bottom',
// })
// this.$router.push(this.getModelPathPrefix() + '/')
// return
// }
// fetch initial page data unless 'creating'
if (this.mode != 'creating') {