mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 12:07:08 +00:00
Add mixin to check access rights client-side.
This replaces the Vuex getters approach (writeaccess, adminaccess) which, as access rights are no longer global but dependent on each project's settings, are no longer appropriate.
This commit is contained in:
31
lib/www/client/source/src/mixins/access.js
Normal file
31
lib/www/client/source/src/mixins/access.js
Normal file
@@ -0,0 +1,31 @@
|
||||
import { mapGetters } from 'vuex';
|
||||
import access from '@/lib/organisations/access';
|
||||
|
||||
export default {
|
||||
name: "AccessMixin",
|
||||
|
||||
computed: {
|
||||
...mapGetters(['user', 'projectConfiguration'])
|
||||
},
|
||||
|
||||
methods: {
|
||||
|
||||
access (operation, item) {
|
||||
if (!item) item = this.projectConfiguration;
|
||||
|
||||
return access(this.user?.organisations ?? {}, item?.organisations ?? {}, operation);
|
||||
},
|
||||
|
||||
readaccess (item) {
|
||||
return this.access('read', item);
|
||||
},
|
||||
|
||||
writeaccess (item) {
|
||||
return this.access('write', item);
|
||||
},
|
||||
|
||||
adminaccess (item) {
|
||||
return this.access('edit', item);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user