Skip to content

AdminController Class

The AdminController class handles administrative actions related to user accounts, roles, and custom data.

Main Functions

  • SetRole(RoleDto role): Assigns a role to a specified user.
  • RemoveRole(RoleDto role): Removes a role from a specified user. Note: The admin role cannot be modified via this method.
  • DeleteAccount(string id): Deletes a user account. Admin accounts cannot be deleted through this function.
  • GetRoles(string id): Retrieves all roles associated with a specified user.
  • GetCustomData(string accountId, string key): Fetches custom data for a user based on a key.
  • SetCustomData(CustomDataDto data): Sets or updates custom data for a user.
  • DeleteCustomData(string accountId, string key): Removes specified custom data from a user's account.
  • GetUser(string accountId): Provides detailed information about a specific user.
  • GetAllUsers(): Lists all user accounts with their details.
  • SetBannedUntil(string accountId, DateTime date): Sets a ban period for a user account. Admin accounts cannot be banned.
  • VerifyTokenAsync(string token): Validates a token and returns the corresponding user's details.

Swagger Documentation

You can also check out the endpoints here: accounts.bytecobra.com.

Security Features

  • Rate Limiting: Applies to all endpoints to prevent abuse and ensure service availability.
  • Admin Verification: Actions require admin authentication, ensuring that only authorized administrators can perform sensitive operations.

Usage Scenario

Administrators or internal services can use this controller to manage user accounts and roles, enforce account bans, and handle custom data associated with users.

Usage

This controller is automatically wired up through ASP.NET Core's MVC framework and listens for HTTP requests matching its routes. It's accessible through standard HTTP client tools or libraries from front-end applications.

For custom functionality, you have the option to extend and customize this controller through subclassing.