
Security News
RubyGems Adds Cooldown Feature to Bundler for Newly Published Gems
RubyGems and Bundler 4.0.13 introduced an opt-in cooldown feature that delays newly published gems during dependency resolution.
@supertokens-plugins/user-banning-nodejs
Advanced tools
Add user banning functionality to your SuperTokens application. This plugin provides endpoints to ban/unban users and automatically revoke sessions of banned users.
npm install @supertokens-plugins/user-banning-nodejs
Initialize the plugin in your SuperTokens backend configuration:
import SuperTokens from "supertokens-node";
import UserBanningPlugin from "@supertokens-plugins/user-banning-nodejs";
import UserRoles from "supertokens-node/recipe/userroles";
SuperTokens.init({
appInfo: {
// your app info
},
recipeList: [
UserRoles.init(), // Required: UserRoles recipe must be initialized
// your other recipes
],
experimental: {
plugins: [
UserBanningPlugin.init({
userBanningPermission: "ban-user", // Optional: defaults to "ban-user"
bannedUserRole: "banned", // Optional: defaults to "banned"
}),
],
},
});
The plugin automatically creates these protected endpoints:
/plugin/supertokens-plugin-user-banning/banban-user (or custom permission){
"userId": "user123", // Required if email not provided
"email": "user@example.com", // Required if userId not provided
"isBanned": true // true to ban, false to unban
}
tenantId (required)/plugin/supertokens-plugin-user-banning/banban-user (or custom permission)tenantId (required)userId (required if email not provided)email (required if userId not provided)| Option | Type | Default | Description |
|---|---|---|---|
userBanningPermission | string | "ban-user" | Permission required to ban/unban users |
bannedUserRole | string | "banned" | Role assigned to banned users |
bannedUserRoleaddBanToCacheremoveBanFromCachegetBanStatusFromCachepreLoadCacheIfNeededBesides using the API endpoints directly, you can also ban users through:
Navigate to your SuperTokens dashboard and add the configured banned role (default: "banned") to any user. This will have the same effect as using the plugin's API endpoints.
Install the React companion plugin to get a user-friendly banning interface:
npm install @supertokens-plugins/user-banning-react
Then initialize it in your frontend:
import SuperTokens from "supertokens-auth-react";
import UserBanningPlugin from "@supertokens-plugins/user-banning-react";
SuperTokens.init({
// ... your configuration
plugins: [
UserBanningPlugin.init({
userBanningPermission: "ban-user", // Should match backend config
bannedUserRole: "banned", // Should match backend config
}),
],
});
The React plugin provides a ban user page accessible at /admin/ban-user with a user-friendly interface for banning and unbanning users.
Below you can find a quick example of how to call the API endpoints.
// Ban a user
const response = await fetch("/plugin/supertokens-plugin-user-banning/ban?tenantId=public", {
method: "POST",
credentials: "include", // Make sure to include the session
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
email: "user@example.com",
isBanned: true,
}),
});
// Check ban status
const statusResponse = await fetch(
"/plugin/supertokens-plugin-user-banning/ban?tenantId=public&email=user@example.com",
{
credentials: "include", // Make sure to include the session
headers: {
// Include session tokens in headers
},
}
);
const status = await statusResponse.json();
console.log(status.banned); // true/false
The plugin returns standardized error responses:
// Bad input
{
"status": "BAD_INPUT_ERROR",
"message": "userId or email is required"
}
// User not found
{
"status": "BAD_INPUT_ERROR",
"message": "user not found"
}
// Server errors
{
"status": "UNKNOWN_ERROR",
"message": "Could not set ban status"
}
FAQs
User Banning Plugin for SuperTokens
We found that @supertokens-plugins/user-banning-nodejs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
RubyGems and Bundler 4.0.13 introduced an opt-in cooldown feature that delays newly published gems during dependency resolution.

Security News
pnpm 11.5 now recognizes npm staged publish approvals in release metadata, preventing those releases from being mistaken for lower-trust package publishes.

Security News
Federal audit finds NIST lacked a plan to clear the NVD backlog, wasted funds on duplicate work, and delayed use of CISA data.