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
export function realtime_check_permission(channel, subscriber) { return permissionsRouter.check(channel,subscriber); }
Method Declaration
Copy
function check(
  channel: Channel,
  subscriber: Subscriber,
): Promise<ChannelPermissions> | ChannelPermissions;
Method Parameters
channelChannelRequired

Channel to check permissions for.


subscriberSubscriberRequired

Subscriber to check permissions for.

Returns
Return Type:Promise<ChannelPermissions> | ChannelPermissions
JavaScript
// In realtime-permissions.js import { permissionsRouter } from "wix-realtime-backend"; // ... export function realtime_check_permission(channel, subscriber) { return permissionsRouter.check(channel, subscriber); }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?