Skip to main content

User Bans

Last updated on

Overview

User bans allow you to restrict access to your game, or to particular in-game features, from players that break your game’s rules or otherwise act inappropriately. There are two ways to ban a user:

  • Account Bans which restrict access to your game by revoking all of the banned player’s access tokens.
  • Feature Bans which restrict access to specific in-game features by invalidating all access tokens for that feature.

Managing user bans includes two main actions: banning a player from your game, and lifting an existing ban from a player. Banning and unbanning players can be done directly from the Admin Portal.

How It Works

Account Ban

When a player that isn’t banned accesses your game, the SDK sends their login request to our IAM service. The IAM service grants the user login request and sends a Success response (status code: 200) and access token back to the SDK, and the player is logged in. Then when the player accesses a resource (such as Lobby) a request is sent from the SDK to the service containing that player’s access token. The backend checks this token, and if the token is not expired and contains the proper permission, the player is granted access to that resource.

If you ban that player from your game, that request will be sent to the IAM service. The IAM service will then revoke the player’s access token, banning them from your game.

If the player tries to access a particular resource after they’ve been banned, the service will respond to the SDK’s request with an invalid token error.

user-ban-management

Feature Ban

When a player is banned from a specific feature, that ban request is sent to the IAM service which will revoke the player’s access token. Then, if that player attempts to access the game again, the SDK will refresh the player’s access token automatically. This refresh will trigger the IAM service to check the player’s bans and remove any permissions related to accessing banned features from that access token. This will enable the player to access other resources in game while restricting their access to the banned feature.

user-ban-management

Managing Bans in the Admin Portal

Ban a Player

  1. In the Admin Portal, open the User menu and type the Email or Display Name of the player you want to ban in the search bar and then click Enter to search.

    user-ban-management

  2. Click View next to the player you want to ban.

  3. In the player’s dashboard, switch to the Bans tab.

    user-ban-management

  4. To ban the player, click the Add Ban button.

    user-ban-management

  5. The Add Ban form appears. Fill in the required information:

    user-ban-management

    • Choose the Ban Type. If you choose Feature Ban, you need to choose the feature you want to restrict. A list of the features that players can be banned from can be found in the table below.

      Ban Type
      Feature RestrictionDescription
      CHAT_SENDPlayer is banned from sending a message.
      CHAT_ALLPlayer is banned from both sending and receiving messages.
      ORDER_AND_PAYMENTPlayer is banned from making purchases in-game.
      STATISTICSPlayer will not have their statistics recorded.
      LEADERBOARDPlayer will not appear on any leaderboards.
      MATCHMAKINGPlayer is banned from matchmaking.
    • Define when the ban will expire in the Ban Expiration field:

      • If you want the ban to expire after a certain amount of time, select Set by duration. Then enter the number of minutes, hours, or days you want the player to be banned for. After this amount of time passes, the ban will expire.
      • If you want the ban to expire on a certain day and time, select Set by expiration date. Then enter the date and time you want the ban to expire.
      • Choose Never if you want the ban to be permanent. Permanent bans can be disabled manually.
    • Select the reason for the ban from the Reason dropdown list. A list of the reasons players can be banned can be found in the table below.

      Ban Reasons
      ReasonDescription
      VIOLENCEPlayer is banned for posting violent content.
      HARASSMENTPlayer is banned for harassing other players.
      HATEFUL_CONDUCTPlayer is banned for acting hatefully towards other players.
      OFFENSIVE_USERNAMEPlayer is banned for having an offensive username.
      IMPERSONATIONPlayer is banned for impersonating other players.
      MALICIOUS_CONTENTPlayer is banned for posting malicious content such as spam, scams, etc.
      SEXUALLY_SUGGESTIVEPlayer is banned for posting sexually explicit or suggestive content.
      SEXUAL_VIOLENCEPlayer is banned for acting sexually violent or exploiting other players.
      EXTREME_VIOLENCEPlayer is banned for extremely violent content such as gore.
      UNDERAGE_USERPlayer is banned for being underage.
      CHEATINGPlayer is banned for cheating.
      TOS_VIOLATIONPlayer is banned for violating the Terms of Service.
    • Type a Comment that includes any relevant information about the ban.

    • Select the Notify user via email checkbox if you want to send a ban notification to the player via email.

    IMPORTANT

    Players that log into your game using 3rd party credentials may only have a headless account in the Admin Portal, which means that their account will have no email address associated with it. Only players that have registered an account in your game or platform, or have upgraded their headless account by registering an email address in your game, will be able to receive an email notification if they’re banned. For more information about headless accounts, see the 3rd-party Login Integration documentation.

    When you’re done, click the Bans button. The new ban will appear in the Bans list.

    user-ban-management

    If you select the Notify user via email option and the banned player’s email address is on record in the Admin Portal, they will receive an email saying that they have been banned, as well as the reason for the ban and how long the ban will be enforced.

    user-ban-management

Unban a Player

To re-enable an expired or disabled ban on a player, or lift an existing ban on a player, follow the steps below:

  1. In the Admin Portal, open the User menu and type the Email or Display Name of the player you want to unban. in the search bar, then click Enter to search.

    user-ban-management

  2. Click View next to the player you want to unban.

  3. In the player’s Bans list you can browse all of the bans that have ever been applied to the player.

    user-ban-management

  4. Click Enable or Disable on the ban listing to enable or disable the ban. A confirmation message will appear. In this case, click Disable to unban the player.

    user-ban-management

  5. After you have disabled the ban, the player will be able to access the game or the feature they were banned from. If you reenable a ban for a player, the player will once again be banned from accessing the game or from the specific feature.

Implementing Bans Using the SDK

Ban a Player In-Game

Use the code below to implement in-game banning of players. This can be useful if you have moderators in your game who need to be able to ban players without being granted access to your Admin Portal.

NOTE

To enable in-game moderators to ban players, those moderators will need to be assigned a game admin role that includes the Ban a Player permission, just like an admin who bans players from the Admin Portal.

string PlayerUserID = "exampleuserid2434";
BanType banType = BanType.Login;
BanReason banReason = BanReason.CHEATING;
DateTime ban_EndDate = DateTime.UtcNow;
ban_EndDate = endDate.AddDays(365);
string comment = "This player caught cheating";
bool notifyUserEmail = false;

AccelBytePlugin.GetUser().BanUser(PlayerUserID, banType, banReason, ban_EndDate, comment, notifyUserEmail, result => {
if (!result.isError) {
Debug.Log("Success ban a player.");
} else {
Debug.Log("Failed to ban a player. Error : " + result.Error.ToString());
}
});

Ban Notifications

Use the code below to implement ban notifications, so that players can be told that they have been banned and the reason why.

AccelBytePlugin.GetLobby().UserBannedNotification += result => {
Debug.Log("You have been banned. reason: " + result.Value.reason);
};
  • To learn more about user accounts, see the User Accounts documentation.