2021-01-30 05:19:43 +00:00
|
|
|
import { useStore } from 'vuex';
|
|
|
|
import { UserSessionState } from 'src/plugins/user/store';
|
2020-11-06 00:17:04 +00:00
|
|
|
|
2021-01-30 05:19:43 +00:00
|
|
|
export function hasPermission(permission: string) {
|
|
|
|
const store = useStore<UserSessionState>();
|
|
|
|
return store.state.users.currentPermissions.includes(permission);
|
2020-11-06 00:17:04 +00:00
|
|
|
}
|
|
|
|
|
2021-01-30 05:19:43 +00:00
|
|
|
export function hasPermissions(needed: string[]) {
|
|
|
|
const store = useStore<UserSessionState>();
|
|
|
|
const permissions = store.state.users.currentPermissions;
|
2021-03-18 16:23:57 +00:00
|
|
|
return needed.every((value) => permissions.includes(value));
|
2020-11-06 00:17:04 +00:00
|
|
|
}
|
2021-01-29 01:29:27 +00:00
|
|
|
|
2021-01-30 05:19:43 +00:00
|
|
|
export function hasSomePermissions(needed: string[]) {
|
|
|
|
const store = useStore<UserSessionState>();
|
|
|
|
const permissions = store.state.users.currentPermissions;
|
2021-03-18 16:23:57 +00:00
|
|
|
return needed.some((value) => permissions.includes(value));
|
2021-01-29 01:29:27 +00:00
|
|
|
}
|