I am using vue-class-component (and vue-property-decorator) in my vue2 project. I would like to incorporate component-level security checking to each component as it is loaded. I envision a signature like this:
@Component
@Security('USERS_LIST')
export default class UserList extends Vue {
...
}
Internally, the parameter passed (USERS_LIST) is checked against some Vuex store, and on failure the user is notified or redirected using Vue-Router. I can handle all the wiring, but I'm a bit lost on how I can create a component-level decorator, or expand the existing @Component decorator on my own.
I feel like I could use a mixin to override a lifecycle method and check state for the security aspect. But how do I define the @Security decorator, and provide it a value per-component?