Access rights
User-specific access rights defined in Description.json and configured in Engineering should be checked and evaluated in Source.js. Depending on the user-specific access rights, specific elements can be switched visible or invisible or enabled or disabled, for example.
The evaluation of the configured access rights is performed via the framework API function "TcHmi.Access.checkAccess()". The current instance of the control is passed to the function (this) and the name of the right to be checked, which must correspond to the definition in Description.json.
// check user access of "myCustomRight" that is defined in the description.json
if (TcHmi.Access.checkAccess(this, 'myCustomRight') === true) {
// current user has the rights to do this
// process actions with the right
// show elements, enable buttons, etc.
}
else {
// Current user has no rights to do this
// process actions without the rights
// hide elements, disable buttons, etc.
}
Since user management only works when authentication is active, the configured functions are not available in live view. |