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:
If a permissions handler for the specified channel or channel resource exists, it's invoked and its result is returned.
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.
If no handler is found for the specified channel, but a default permissions handler exists, it's invoked and its result is returned.
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:
export function realtime_check_permission(channel, subscriber) {
return permissionsRouter.check(channel,subscriber);
}
function check(
channel: Channel,
subscriber: Subscriber,
): Promise<ChannelPermissions> | ChannelPermissions;
Channel to check permissions for.
Subscriber to check permissions for.
// In realtime-permissions.js
import { permissionsRouter } from "wix-realtime-backend";
// ...
export function realtime_check_permission(channel, subscriber) {
return permissionsRouter.check(channel, subscriber);
}
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.