Skip to main content

getModelPermission

@webda/core


Function: getModelPermission()

getModelPermission(object, context, action, model?): Promise<any>

Defined in: packages/core/src/models/permissions.ts:153

Ask the model whether the current caller may perform action on an object

The question goes through the static canAct(context, action, object) of the model class (see Model.canAct): the base implementation delegates to the object's instance canAct, and denies when there is none. true allows; anything else (false, a refusal reason string, undefined...) refuses, and so does a canAct that throws.

Parameters​

object​

any

the model instance (the new, unsaved object on create)

context​

IOperationContext

the caller context

action​

string

the action name ("get", "create", "update", "delete", an action name or "attribute.action")

model?​

any

the model class (defaults to the object's class)

Returns​

Promise<any>

true when allowed, otherwise the refusal (a reason string or false)