wv-authorize
Purpose
Attribute only tag helper. Will render the attributed element and its contents, only if the authorize check is successful. The wv-authorize is used alone
or in conjunction with erp-allow-roles and erp-block-roles.
Properties
| name | description |
|---|---|
wv-authorize |
html target: object type: default value: is required: A role name or a csv list of role names, which the user needs to have in order to access the element. |
erp-allow-roles |
html target: object type: default value: is required: Used as HTML Attribute to enabled the authorizations |
erp-block-roles |
html target: object type: default value: is required: A role name or a csv list of role names, which the user should not have in order to access the element. With priority over the previous attribute |
Example
| goal | code |
|---|---|
| User is authenticated | <div wv-authorize>...</div> |
| User is guest | <div wv-authorize erp-allow-roles="guest">...</div> |
User doesn't have administrator role |
<div wv-authorize erp-block-roles="administrator">...</div> |
User is not guest |
<div wv-authorize erp-block-roles="guest">...</div> |
User has either administrator or regular role |
<div wv-authorize erp-allow-roles="guest,regular">...</div> |
User has administrator but not manager role |
<div wv-authorize erp-allow-roles="administrator" erp-block-roles="manager">...</div> |
<div wv-authorize erp-allow-roles="administrator,manager" erp-block-roles="sales"></div>