Module: Core/Acl

The ACL module provides methods to check ACLs for modules and fields.

Methods


<static> clearCache()

This method has no effect. Do not use it.

Deprecated:
  • since 7.10

<static> hasAccess(action, module [, options])

Checks ACLs to see if the current user can perform the given action on a given module or record.

Parameters:
Name Type Argument Description
action string

Action name.

module string

Module name.

options Object <optional>

Options.

Properties
Name Type Argument Description
field string <optional>

Name of the field to check access to.

acls string <optional>

Record's ACLs that take precedence over the module's ACLs. These are normally supplied by the server as part of the data response in _acl.

Returns:

true if the current user has access to the given action; false otherwise.

Type
boolean

<static> hasAccessToAny(action)

Checks ACLs to see if the current user can perform the given action on any model.

const Acl = require('core/acl');

// Check whether user has `admin` access for any module.
Acl.hasAccessToAny('admin');

// Check whether user has `developer` access for any module.
Acl.hasAccessToAny('developer');
Parameters:
Name Type Description
action string

Action name.

Returns:

true if the current user has access to the given action; false otherwise.

Type
boolean

<static> hasAccessToModel(action, model [, field])

Checks ACLs to see if the current user can perform the given action on a given model's field.

Parameters:
Name Type Argument Description
action string

Action name.

model Object

Model instance.

field string <optional>

Name of the model field.

Returns:

true if the current user has access to the given action; false otherwise.

Type
boolean