flaschengeist-frontend/src/utils/permission.ts

17 lines
641 B
TypeScript
Raw Normal View History

import { Store } from 'vuex';
import { StateInterface } from 'src/store';
2021-01-21 20:07:49 +00:00
export function hasPermission(permission: string, store: Store<StateInterface>) {
return store.state.user.currentPermissions.includes(permission);
}
export function hasPermissions(needed: string[], store: Store<StateInterface>) {
const permissions = store.state.user.currentPermissions;
return needed.every((value) => permissions.includes(value));
}
2021-01-29 01:29:27 +00:00
export function hasSomePermissions(needed: string[], store: Store<StateInterface>) {
const permissions = store.state.user.currentPermissions;
return needed.some((value) => permissions.includes(value));
2021-01-29 01:29:27 +00:00
}