File

core/common/permissions.service.ts

Index

Methods

Constructor

constructor(appState: AppStateService, inventory: InventoryService, user: UserService)
Parameters :
Name Type Optional
appState AppStateService No
inventory InventoryService No
user UserService No

Methods

canEdit
canEdit(roleIds, mo: IManagedObject | IIdentified, config: CanEditConfig)

Checks if the current user has write permissions for the given mo. (either through global role, individual device permissions or via inventory roles).

  • skipRolesCheck: boolean - skips roles check,
  • skipOwnerCheck: boolean - skips ownership check,
  • skipRequestCheck: boolean - skips checks with a query to the inventory API. UI will make a query to backend whether the user can edit the managed object. A rejection from BE indicates a lack of permission.
Parameters :
Name Type Optional Default value Description
roleIds No

Array of roles which the current user should have.

mo IManagedObject | IIdentified No

The managed object for which we are checking whether the user has access.

config CanEditConfig No { skipRolesCheck: false, skipOwnerCheck: false, skipRequestCheck: false }

A configuration object that can take the following values:

  • skipRolesCheck: boolean - skips roles check,
  • skipOwnerCheck: boolean - skips ownership check,
  • skipRequestCheck: boolean - skips checks with a query to the inventory API. UI will make a query to backend whether the user can edit the managed object. A rejection from BE indicates a lack of permission.
Returns : unknown
Protected Async checkIfOwner
checkIfOwner(mo)
Decorators :
@memoize(undefined)
Parameters :
Name Optional
mo No
Returns : unknown
Protected checkWithRequest
checkWithRequest(mo)
Decorators :
@memoize(undefined)
Parameters :
Name Optional
mo No
Returns : any
hasAllRoles
hasAllRoles(roleIds: string[])
Parameters :
Name Type Optional
roleIds string[] No
Returns : any
hasAnyRole
hasAnyRole(roleIds: string[])
Parameters :
Name Type Optional
roleIds string[] No
Returns : any
hasRole
hasRole(roleId: string)
Parameters :
Name Type Optional
roleId string No
Returns : any

results matching ""

    No results matching ""