youAreBanned
When a banned user tries to join the chat room, or tries to send a message, the chat room emits the not_authorized event to the SDK.
caution
There is no youarebanned event on the SDK. A listener registered for youarebanned will never fire. Listen for not_authorized instead.
JavaScript
frame1.on("not_authorized", (message) => {
console.log("not_authorized", message);
});
Properties
| Properties | Description | Type |
|---|---|---|
| message | Reason the action was refused. You cannot join the room, because you are banned when the user tried to join, You cannot send message to a room, because you are banned when the user tried to send a message. | String |
JSON Sample Response
{
"message": "You cannot join the room, because you are banned"
}
Telling a ban apart from other authorization failures
The not_authorized event is also emitted when a user is refused for reasons other than a ban. A ban payload contains only message, while other authorization failures also carry an error property set to not_authorized:
JSON Sample Response — not banned, not authorized
{
"error": "not_authorized",
"message": "You are not authorized to join the room"
}
After a ban the chat room shows the banned message to that user and closes their connection, so no further events arrive for them.