v-access-control
is an implementation of front-end access control on DOM/Component level. Custom directive has been applied, in the form of v-access, to annotate accessible authorities on DOM/Component.
On developing: access control of route level
npm i v-access-control
or
yarn add v-access-control
<my-component v-access.AUTH1.AUTH2 {...otherProps}></my-component>
<div class="any-dom" v-access.AUTH1.AUTH2>
<!-- ... -->
</div>
By this annotation, this element will only display if user acquire AUTH1 and AUTH2.
<my-component v-access:AUTH1|AUTH2 {...otherProps}></my-component>
<div class="any-dom" v-access:AUTH1|AUTH2>
<!-- ... -->
</div>
By this annotation, this element will only display if user acquire AUTH1 or AUTH2.
In template:
<my-component v-access="accessAllowed"></my-component>
<div class="any-dom" v-access="accessAllowed">
<!-- ... -->
</div>
In script:
data() {
return {
accessAllowed: {
access: ['AUTH1', 'AUTH2'],
anyAccess: ['AUTH3', 'AUTH4']
}
}
}
Consequently, user who acquire AUTH1 and AUTH2 and any one of AUTH3, AUTH4
will be allowed to observe this element.
{
userAuthFactory: void => string[]
}