check( )


Checks the permissions for a subscriber on a channel or channel resource.

The check() function returns a Promise that resolves to the permissions for the specified user on the specified channel or channel resource.

The check is performed as follows:

  1. If a permissions handler for the specified channel or channel resource exists, it's invoked and its result is returned.

  2. If no handler is found for the specified channel resource, but a handler exists for the resource's channel, it's invoked and its result is returned.

  3. If no handler is found for the specified channel, but a default permissions handler exists, it's invoked and its result is returned.

  4. If the default handler has not been found, the default permissions are returned.

    The default permissions are: {"read": true}

This function is typically called in the body of the realtime_check_permission() function like so:

Copy
Method Declaration
Copy
Method Parameters
channelChannelRequired

Channel to check permissions for.


subscriberSubscriberRequired

Subscriber to check permissions for.

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