default( )


Sets a permissions handler for default permissions.

The handler set by the default() function is used for permission checks by the permissions router for all channels where an explicit handler has not been added. For channel resources, if no explicit handler has been set, the resource will inherit the permissions of its parent channel.

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

  • channel: A, permissions: no handler specified
  • channel: A, resource: 1, permissions: no handler specified
  • channel: A, resource: 2, permissions: handler is specified

Permissions will be checked as follows:

  • A: use the handler set by default() function
  • A, 1: use the handler set by default() function
  • A, 2: use the handler set by add() function for this resource

If no default handler is set, subscribers to channels without explicit permissions handlers will receive the following permissions: {"read": true}

Method Declaration
Copy
Method Parameters
handlerfunctionRequired

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

Was this helpful?
Yes
No