realtime_check_permission( )


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

The realtime_check_permission hook is triggered when a site visitor subscribes to a channel to check what permissions the subscriber will have.

The realtime_check_permission() function is not a function that you call from your code. You define the function in a file named realtime-permissions.js in your site's Backend section.

If this function is not defined, all subscribers will receive the default permissions, which are: {"read": true}

Implement permissions logic for channels and subscribers by either:

  • Including all permissions logic in the body of this function.
  • Use the PermissionsRouter to add permissions logic per channel. Then call check() in the body of this function and return the permissions object it returns.

Note: When previewing your site, permissions for read are always granted.

Method Declaration
Copy
Method Parameters
channelChannelRequired

The channel, and optionally the resource, to check permissions for.


subscriberSubscriberRequired

The subscriber to check permissions for.

Returns
Return Type:Promise<ChannelPermissions>
Was this helpful?
Yes
No