add( )


Sets a permissions handler for a specific channel or channel resource.

The handler set by the add() function is used for permission checks by the permissions router for the channel or channel resource specified in the channel property.

Adding a handler to a specific channel without a specified resource adds a handler for all permissions checks on the channel and all permissions checks on any of the channel's resources that do not have their own permissions handlers.

For example, suppose you have the following channel, resources, and permissions:

  • channel: A, permissions: handler X is specified using the add() function
  • channel: A, resource: 1, permissions: handler Y is specified using the add() function
  • channel: A, resource: 2, permissions: no handler is specified

Permissions will be checked as follows:

  • A: use handler X
  • A, 1: use handler Y
  • A, 2: use handler X
Method Declaration
Copy
Method Parameters
channelChannelRequired

Channel or channel resource to add a permissions handler for.


handlerfunctionRequired

handler(channel: Channel, subscriber: Subscriber): Promise<ChannelPermissions> | ChannelPermissions The name of the function or the function expression to use when checking permissions for the specified channel.

Returns
Return Type:Promise<void> | void
Did this help?