Table of Contents

Interface IAccountService

Namespace
FishMMO.Database.Npgsql.Services.Interfaces
Assembly
FishMMO-DB.dll

Service interface for account operations following ISP principle. All operations are async and return DatabaseResult for consistent error handling. Implements execution strategies for automatic retry on transient database failures.

public interface IAccountService : IExistsByKeyAction<string>
Inherited Members

Remarks

This service provides account management operations including:

  • Account creation with atomic UPSERT to prevent race conditions
  • Login authentication with SRP (Secure Remote Password) protocol support
  • Last login timestamp tracking
  • Account existence checks

Methods that perform database write operations use execution strategies to automatically retry on transient failures (up to 3 attempts by default). This includes connection timeouts, deadlocks, and network interruptions.

All methods follow consistent validation and error handling patterns:

  • Username validation (3-32 characters, non-empty)
  • Null safety with nullable reference types
  • DatabaseResult pattern for safe, typed error handling
  • Custom exceptions with sanitized messages for security

Methods

BanAsync(string, DateTime?, string?, string?, CancellationToken)

Bans an account: drops it to AccessLevel.Banned, revokes its auth tokens and Control Panel sessions, queues a kick so the game servers disconnect it, and records who banned it, why, and when the ban lifts.

Task<DatabaseResult> BanAsync(string accountName, DateTime? bannedUntilUtc, string? bannedBy, string? reason, CancellationToken cancellationToken = default)

Parameters

accountName string

Account to ban. Matched case-insensitively.

bannedUntilUtc DateTime?

When the ban lifts, or null for a permanent ban.

bannedBy string

Operator account applying the ban, or null when not recorded.

reason string

The reason, or null when not recorded.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<DatabaseResult>

Success, or DB_NOT_FOUND when no such account exists.

Remarks

All four writes land together or none of them do. A half-applied ban leaves the account playing: the access level is the login gate and nothing else, so lowering it alone stops the next sign-in and does nothing to the session already connected, while revoking tokens alone lets the player sign straight back in. The failure this atomicity exists to prevent is exactly that — an operator who is told the ban succeeded, watching the banned account keep playing.

This layer does no policy checking. Who may ban whom is the caller's decision, and every caller must record the ban in the audit log.

A null bannedUntilUtc is a permanent ban. A temporary one is lifted by FetchForLoginAsync(string, bool, CancellationToken) at the first sign-in attempt after the instant passes, which restores Player.

The only ban. A one-argument overload that recorded neither actor nor reason was removed (issue #267): an account page showing "banned by: —, reason: —" is a ban nobody can explain or appeal, and every real caller already passed both.

ClearAuthFailuresAsync(string, AuthFailureKind, CancellationToken)

Clears one step's failure count after it succeeds.

Task<DatabaseResult> ClearAuthFailuresAsync(string accountName, AuthFailureKind kind, CancellationToken cancellationToken = default)

Parameters

accountName string
kind AuthFailureKind
cancellationToken CancellationToken

Returns

Task<DatabaseResult>

ClearAuthLockoutAsync(string, CancellationToken)

Lifts both sign-in lockouts: the staff action. True when one was in force.

Task<DatabaseResult<bool>> ClearAuthLockoutAsync(string accountName, CancellationToken cancellationToken = default)

Parameters

accountName string
cancellationToken CancellationToken

Returns

Task<DatabaseResult<bool>>

ClearMuteAsync(string, CancellationToken)

Lifts an account's chat mute, clearing who set it and why.

Task<DatabaseResult> ClearMuteAsync(string accountName, CancellationToken cancellationToken = default)

Parameters

accountName string

Account to unmute. Matched case-insensitively.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<DatabaseResult>

Success, or DB_NOT_FOUND when no such account exists.

ClearTotpAsync(string, CancellationToken)

Clears all TOTP fields when a user disables 2FA. Atomically resets totp_secret, totp_enabled, totp_verified_at, and last_totp_window. Recovery codes should be invalidated separately via ITwoFactorRecoveryCodeService.

Task<DatabaseResult> ClearTotpAsync(string accountName, CancellationToken cancellationToken = default)

Parameters

accountName string

The account name.

cancellationToken CancellationToken

Token to cancel the operation.

Returns

Task<DatabaseResult>

DatabaseResult indicating success or failure.

ExpirePhoneVerifyCodeAsync(string, int, CancellationToken)

Expires the account's phone verification code NOW, but only if it is still verifyCode. See ExpireVerifyCodeAsync(string, int, CancellationToken).

Task<DatabaseResult<bool>> ExpirePhoneVerifyCodeAsync(string accountName, int verifyCode, CancellationToken cancellationToken = default)

Parameters

accountName string
verifyCode int
cancellationToken CancellationToken

Returns

Task<DatabaseResult<bool>>

True when that code was expired; false when the account holds a different code.

ExpireVerifyCodeAsync(string, int, CancellationToken)

Expires the account's email verification code NOW, but only if it is still verifyCode.

Task<DatabaseResult<bool>> ExpireVerifyCodeAsync(string accountName, int verifyCode, CancellationToken cancellationToken = default)

Parameters

accountName string
verifyCode int
cancellationToken CancellationToken

Returns

Task<DatabaseResult<bool>>

True when that code was expired; false when the account holds a different code.

Remarks

For a code that was stored and then could not be delivered: expiring it makes the next sign-in issue a fresh one instead of the player waiting out a code they never received. Conditional on the code, because doing it by re-writing the code unconditionally would retire a NEWER code another server issued in the meantime — the one the player may be holding (issue #267).

FetchAdminAsync(string, CancellationToken)

Fetches a single account for an operator.

Task<DatabaseResult<AccountAdminData>> FetchAdminAsync(string accountName, CancellationToken cancellationToken = default)

Parameters

accountName string

Account to fetch. Matched case-insensitively.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<DatabaseResult<AccountAdminData>>

The account, or DB_NOT_FOUND when no such account exists.

Remarks

Not FetchForLoginAsync(string, bool, CancellationToken). That method refuses banned accounts and reports a missing account and a banned one with the same message, because a login path that distinguished them would be an account-enumeration oracle. Both behaviours are wrong here: the operator most likely to open an account page is the one looking at a ban, and an operator who cannot tell "no such account" from "banned" cannot do the job.

The caller is responsible for the access-level check that makes that distinction safe to expose, and for auditing the read if the deployment audits reads.

FetchAuthLockoutAsync(string, CancellationToken)

Reads an account's sign-in lockouts. An unknown account reads as locked out of nothing.

Task<DatabaseResult<AuthLockoutState>> FetchAuthLockoutAsync(string accountName, CancellationToken cancellationToken = default)

Parameters

accountName string
cancellationToken CancellationToken

Returns

Task<DatabaseResult<AuthLockoutState>>

FetchForLoginAsync(string, bool, CancellationToken)

Retrieves account authentication data for login.

Task<DatabaseResult<AccountData>> FetchForLoginAsync(string username, bool email = false, CancellationToken cancellationToken = default)

Parameters

username string

The account name or email to query, depending on email.

email bool

When false, username is treated as the account name (3-32 chars). When true, it is treated as an email (max 320 chars).

cancellationToken CancellationToken

Token to cancel the asynchronous operation.

Returns

Task<DatabaseResult<AccountData>>

DatabaseResult containing AccountData with authentication credentials on success, or error information on failure.

Remarks

This method uses LINQ query which automatically benefits from EF Core's configured retry policy for transient failures.

Success: Returns AccountData with salt, verifier, access level, and timestamps.

  • (Banned, null): Account exists but is banned Success: Returns AccountData with salt, verifier, access level, and timestamps. Failure cases:
  • VALIDATION_ERROR: Username or email validation failed
  • DB_NOT_FOUND: Account does not exist
  • ACCOUNT_BANNED: Account exists but is banned
  • DB_CONNECTION_FAILED: Database connection error (transient)
  • DB_TIMEOUT: Query timeout (transient)

Security Note: Does not distinguish between non-existent accounts and banned accounts in error messages to prevent username enumeration attacks.

The returned AccountData DTO is a defensive copy and can be safely used after the database context is disposed.

FetchLastLoginAsync(string, bool, CancellationToken)

Gets the last login time for an account.

Task<DatabaseResult<DateTime>> FetchLastLoginAsync(string username, bool email = false, CancellationToken cancellationToken = default)

Parameters

username string

The account name or email to query, depending on email.

email bool

When false, username is treated as the account name (3-32 chars). When true, it is treated as an email (max 320 chars).

cancellationToken CancellationToken

Token to cancel the asynchronous operation.

Returns

Task<DatabaseResult<DateTime>>

DatabaseResult containing the last login timestamp on success, or error information on failure.

Remarks

This method uses LINQ query which automatically benefits from EF Core's configured retry policy for transient failures.

Success: Returns the last login timestamp. Failure cases:

  • VALIDATION_ERROR: Username or email validation failed
  • DB_NOT_FOUND: Account does not exist
  • DB_CONNECTION_FAILED: Database connection error (transient)
  • DB_TIMEOUT: Query timeout (transient)

FetchPendingTotpSecretAsync(string, CancellationToken)

The staged re-enrolment secret, encrypted, or null when none is staged.

Task<DatabaseResult<string?>> FetchPendingTotpSecretAsync(string accountName, CancellationToken cancellationToken = default)

Parameters

accountName string
cancellationToken CancellationToken

Returns

Task<DatabaseResult<string>>

NotFound when the account does not exist.

PersistAccessLevelAsync(string, byte, CancellationToken)

Marks an account verified without requiring a verification code, clearing any pending code in the process.

This is the server-initiated counterpart to PersistVerifiedAsync and exists for the development-only AutoVerifyAccounts path, where no code is ever generated or emailed. It performs no code check, so it must never be reachable from a client-supplied value — client-driven verification goes through PersistVerifiedAsync, which validates the code atomically.

Task<DatabaseResult> PersistAccessLevelAsync(string accountName, byte accessLevel, CancellationToken cancellationToken = default)

Parameters

accountName string

The account name.

accessLevel byte

The new level.

cancellationToken CancellationToken

Token to cancel the operation.

Returns

Task<DatabaseResult>

DatabaseResult indicating success or failure.

Remarks

The level is the account's whole authorization surface, in the game and in the Control Panel alike, so this is the single most consequential write in this service. It does no policy checking of its own — who may promote whom, and how far, is the caller's to decide and depends on the caller's own level, which this layer cannot see.

Every caller must record the change in the audit log. A level that changed with no record of who changed it is indistinguishable from a compromise.

PersistAgeAsync(string, int, CancellationToken)

Updates the age for an account.

Task<DatabaseResult> PersistAgeAsync(string accountName, int age, CancellationToken cancellationToken = default)

Parameters

accountName string

The account name.

age int

The age value.

cancellationToken CancellationToken

Token to cancel the operation.

Returns

Task<DatabaseResult>

DatabaseResult indicating success or failure.

PersistAsync(string, string, string, string, int, CancellationToken)

Creates a new account with the specified credentials.

Task<DatabaseResult> PersistAsync(string accountName, string salt, string verifier, string email, int age, CancellationToken cancellationToken = default)

Parameters

accountName string

The account name. Must be 3-32 characters.

salt string

The salt for SRP password hashing. Must not be null or whitespace.

verifier string

The verifier for SRP password hashing. Must not be null or whitespace.

email string

The account email. Must not be empty and must not exceed 320 characters.

age int

The account holder age. Must be between 0 and 200.

cancellationToken CancellationToken

Token to cancel the asynchronous operation.

Returns

Task<DatabaseResult>

DatabaseResult indicating success or failure with error details.

Remarks

Success: Account created with Player access level and current timestamp. Failure cases:

  • VALIDATION_ERROR: Invalid username, salt, verifier, email, or age
  • UNIQUE_VIOLATION: Account name already exists (non-transient)
  • DATABASE_ERROR: Unexpected database error

PersistAutoVerifiedAsync(string, CancellationToken)

Marks an account verified without requiring a verification code, clearing any pending code in the process.

This is the server-initiated counterpart to PersistVerifiedAsync and exists for the development-only AutoVerifyAccounts path, where no code is ever generated or emailed. It performs no code check, so it must never be reachable from a client-supplied value — client-driven verification goes through PersistVerifiedAsync, which validates the code atomically.

Task<DatabaseResult> PersistAutoVerifiedAsync(string accountName, CancellationToken cancellationToken = default)

Parameters

accountName string

The account name.

cancellationToken CancellationToken

Token to cancel the operation.

Returns

Task<DatabaseResult>

DatabaseResult indicating success or failure.

PersistChannelsVerifiedAsync(string, AccountVerificationChannels, CancellationToken)

Verifies an account without a code: marks the given channels proven and sets verified. The SMS channel is only marked when a number is on record; Discord is never marked, because a proven Discord channel means a linked Discord user.

Task<DatabaseResult> PersistChannelsVerifiedAsync(string accountName, AccountVerificationChannels channels, CancellationToken cancellationToken = default)

Parameters

accountName string
channels AccountVerificationChannels
cancellationToken CancellationToken

Returns

Task<DatabaseResult>

Remarks

For an account IsWaived(in AccountData, AccountVerificationChannels) — verification is required but no enabled channel can reach it. Server-initiated only; never reachable from a client-supplied value.

PersistDiscordVerifyCodeAsync(string, int, CancellationToken)

Issues the account's Discord verification code and wakes the Discord bot to deliver it.

Task<DatabaseResult<bool>> PersistDiscordVerifyCodeAsync(string accountName, int verifyCode, CancellationToken cancellationToken = default)

Parameters

accountName string
verifyCode int
cancellationToken CancellationToken

Returns

Task<DatabaseResult<bool>>

True when this call issued the code.

Remarks

Once per account, ever. Nothing is written when a code was already issued, the DM has been sent or taken by the bot, the account has no Discord username, or it is already verified: the one DM carries this code, and replacing it would strand a DM nobody will ever resend. See DiscordVerification.

PersistEmailAsync(string, string?, CancellationToken)

Updates the email address for an account.

Task<DatabaseResult> PersistEmailAsync(string accountName, string? email, CancellationToken cancellationToken = default)

Parameters

accountName string

The account name.

email string

The new email address, or null to clear.

cancellationToken CancellationToken

Token to cancel the operation.

Returns

Task<DatabaseResult>

DatabaseResult indicating success or failure.

PersistLastLoginAsync(string, CancellationToken)

Updates the last login timestamp for an account atomically. Uses execution strategy for automatic retry on transient failures.

Task<DatabaseResult> PersistLastLoginAsync(string accountName, CancellationToken cancellationToken = default)

Parameters

accountName string

The account name. Must be 3-32 characters.

cancellationToken CancellationToken

Token to cancel the asynchronous operation.

Returns

Task<DatabaseResult>

DatabaseResult indicating success or failure with error details.

Remarks

Uses atomic UPDATE without loading entity to prevent race conditions. Wrapped in execution strategy for automatic retry on transient failures.

Success: Last login timestamp updated to current database server time. Failure cases:

  • VALIDATION_ERROR: Invalid username (length or format)
  • DB_NOT_FOUND: Account does not exist
  • DB_CONNECTION_FAILED: Database connection error (transient)
  • DB_TIMEOUT: Operation timeout (transient)
  • DB_QUERY_FAILED: Unexpected database error

PersistLastTotpWindowAsync(string, long, CancellationToken)

Updates the last TOTP time-step window used for an account, preventing replay attacks. Only updates if the new window is greater than the stored value.

Task<DatabaseResult> PersistLastTotpWindowAsync(string accountName, long totpWindow, CancellationToken cancellationToken = default)

Parameters

accountName string

The account name.

totpWindow long

The time-step window of the verified code.

cancellationToken CancellationToken

Token to cancel the operation.

Returns

Task<DatabaseResult>

DatabaseResult indicating success or failure.

PersistMuteAsync(string, DateTime?, string?, string?, CancellationToken)

Mutes an account in chat, silencing every character it owns.

Task<DatabaseResult> PersistMuteAsync(string accountName, DateTime? mutedUntilUtc, string? mutedBy, string? reason, CancellationToken cancellationToken = default)

Parameters

accountName string

Account to mute. Matched case-insensitively.

mutedUntilUtc DateTime?

When the mute lifts, or null for no end.

mutedBy string

Operator account applying the mute.

reason string

The reason recorded with it.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<DatabaseResult>

Success, or DB_NOT_FOUND when no such account exists.

Remarks

Replaces any mute already on the account rather than extending it: the operator applying the mute has just decided how long it should be, and quietly keeping a longer earlier one would contradict the acknowledgement they are shown. Game servers read the mute when a character loads; a character already in the world is silenced by the server that applied it and by any other only when it next loads there.

PersistPendingTotpSecretAsync(string, string, CancellationToken)

Stages a re-enrolment's encrypted TOTP secret without touching the live one.

Task<DatabaseResult> PersistPendingTotpSecretAsync(string accountName, string encryptedTotpSecret, CancellationToken cancellationToken = default)

Parameters

accountName string
encryptedTotpSecret string
cancellationToken CancellationToken

Returns

Task<DatabaseResult>

NotFound when the account does not exist.

Remarks

Sign-in never reads the pending secret, so an abandoned re-enrolment leaves the account's authenticator working (issue #267). A later staging replaces an earlier one. Promoted by PromotePendingTotpSecretAsync(string, long, CancellationToken) once a code from the new authenticator verifies.

PersistPhoneVerifyCodeAsync(string, int, DateTime, CancellationToken)

Records an outstanding SMS verification code. Refused when the account has no number.

Task<DatabaseResult> PersistPhoneVerifyCodeAsync(string accountName, int verifyCode, DateTime expiresUtc, CancellationToken cancellationToken = default)

Parameters

accountName string
verifyCode int
expiresUtc DateTime
cancellationToken CancellationToken

Returns

Task<DatabaseResult>

PersistProfileAsync(string, AccountProfileData, CancellationToken)

Writes the optional contact and identity details, and the verification channels chosen.

Task<DatabaseResult> PersistProfileAsync(string accountName, AccountProfileData profile, CancellationToken cancellationToken = default)

Parameters

accountName string
profile AccountProfileData
cancellationToken CancellationToken

Returns

Task<DatabaseResult>

Remarks

Validated by AccountProfileRules. A changed phone number loses its verification and any outstanding SMS code; verified is not touched, so editing a number never locks a player out of signing in.

PersistSrpCredentialsAsync(string, string, string, CancellationToken)

Replaces the SRP salt and verifier for an account, for a password change.

Task<DatabaseResult> PersistSrpCredentialsAsync(string accountName, string salt, string verifier, CancellationToken cancellationToken = default)

Parameters

accountName string

The account name.

salt string

The new SRP salt, derived client-side.

verifier string

The new SRP verifier, derived client-side.

cancellationToken CancellationToken

Token to cancel the operation.

Returns

Task<DatabaseResult>

DatabaseResult indicating success or failure.

Remarks

The caller must already have proved possession of the CURRENT password — this method performs no such check. The panel proves it by running a full SRP exchange against the stored verifier before calling here; the plaintext password is never seen by either side, so there is nothing else this layer could verify.

PersistTotpEnabledAsync(string, bool, CancellationToken)

Enables or disables TOTP two-factor authentication for an account.

Task<DatabaseResult> PersistTotpEnabledAsync(string accountName, bool enabled, CancellationToken cancellationToken = default)

Parameters

accountName string

The account name.

enabled bool

Whether TOTP should be enabled.

cancellationToken CancellationToken

Token to cancel the operation.

Returns

Task<DatabaseResult>

DatabaseResult indicating success or failure.

PersistTotpSecretAsync(string, string, CancellationToken)

Stores the encrypted TOTP secret and enables TOTP for an account. Called during 2FA enrollment after the server generates the secret.

Task<DatabaseResult> PersistTotpSecretAsync(string accountName, string encryptedTotpSecret, CancellationToken cancellationToken = default)

Parameters

accountName string

The account name.

encryptedTotpSecret string

The Base32-encoded TOTP secret, encrypted at rest by the server.

cancellationToken CancellationToken

Token to cancel the operation.

Returns

Task<DatabaseResult>

DatabaseResult indicating success or failure.

PersistTotpVerifiedAtAsync(string, long, CancellationToken)

Records the first successful TOTP verification timestamp, confirming 2FA setup. Atomically sets totp_verified_at and updates last_totp_window.

Task<DatabaseResult> PersistTotpVerifiedAtAsync(string accountName, long totpWindow, CancellationToken cancellationToken = default)

Parameters

accountName string

The account name.

totpWindow long

The time-step window of the verified code.

cancellationToken CancellationToken

Token to cancel the operation.

Returns

Task<DatabaseResult>

DatabaseResult indicating success or failure.

PersistVerificationEmailSentAsync(string, CancellationToken)

Records that the verification email has been successfully sent via SMTP. Once set, login is blocked for unverified accounts until the user provides the correct verify code.

Task<DatabaseResult> PersistVerificationEmailSentAsync(string accountName, CancellationToken cancellationToken = default)

Parameters

accountName string

The account name.

cancellationToken CancellationToken

Token to cancel the operation.

Returns

Task<DatabaseResult>

DatabaseResult indicating success or failure.

PersistVerifiedByCodeAsync(string, int, CancellationToken)

Redeems a verification code from any channel, in one conditional update.

Task<DatabaseResult<AccountVerificationChannels>> PersistVerifiedByCodeAsync(string accountName, int verifyCode, CancellationToken cancellationToken = default)

Parameters

accountName string
verifyCode int
cancellationToken CancellationToken

Returns

Task<DatabaseResult<AccountVerificationChannels>>

The channel or channels the code proved.

Remarks

The code is matched against every code the account holds — email, SMS and Discord — and a match on any one of them verifies the account. The update also clears every other outstanding code and the failed-code count. A Discord match links the account to the Discord user the DM reached, unless that user is already linked to a different account, in which case it does not match.

Only an unverified account can match. A wrong code, an expired one, an unknown account and a verified account all fail with the same validation error.

PersistVerifyCodeAsync(string, int, DateTime, CancellationToken)

Sets the verification code for an account, along with the UTC expiry timestamp after which the code is no longer redeemable.

Task<DatabaseResult> PersistVerifyCodeAsync(string accountName, int verifyCode, DateTime expiresUtc, CancellationToken cancellationToken = default)

Parameters

accountName string

The account name.

verifyCode int

The randomly generated verification code.

expiresUtc DateTime

UTC instant after which the code is invalid.

cancellationToken CancellationToken

Token to cancel the operation.

Returns

Task<DatabaseResult>

DatabaseResult indicating success or failure.

PromotePendingTotpSecretAsync(string, long, CancellationToken)

Makes the staged secret live, in one statement: it replaces the live secret, two-factor is enabled, the confirmation time is recorded and the replay window starts at totpWindow.

Task<DatabaseResult<bool>> PromotePendingTotpSecretAsync(string accountName, long totpWindow, CancellationToken cancellationToken = default)

Parameters

accountName string

The account.

totpWindow long

The window of the code that confirmed the new authenticator.

cancellationToken CancellationToken

Token to cancel the operation.

Returns

Task<DatabaseResult<bool>>

True when a staged secret was promoted; false when none was staged.

RecordAuthFailureAsync(string, AuthFailureKind, int, TimeSpan, TimeSpan, CancellationToken)

Counts one failed sign-in step and locks that step once threshold failures land inside window.

Task<DatabaseResult<DateTime?>> RecordAuthFailureAsync(string accountName, AuthFailureKind kind, int threshold, TimeSpan window, TimeSpan lockout, CancellationToken cancellationToken = default)

Parameters

accountName string
kind AuthFailureKind
threshold int
window TimeSpan
lockout TimeSpan
cancellationToken CancellationToken

Returns

Task<DatabaseResult<DateTime?>>

When the step is now locked until, or null when it is not locked.

Remarks

In the database, in one statement, so every login server and the panel share the count and concurrent failures cannot lose an increment. Passwords and authenticator codes are counted apart.

An unknown or malformed account name succeeds with null. The caller must answer a locked account and a wrong password identically to the client, or the lockout becomes a way to learn which accounts exist.

RecordVerificationFailureAsync(string, CancellationToken)

Counts an incorrect verification code against an unverified account.

Task<DatabaseResult<int>> RecordVerificationFailureAsync(string accountName, CancellationToken cancellationToken = default)

Parameters

accountName string
cancellationToken CancellationToken

Returns

Task<DatabaseResult<int>>

The count since the last correct code, or 0 for an unknown or already verified account.

Remarks

In the database, so the login servers and the panel share one count. Callers go through VerificationFailureTicket.RecordAsync, which opens the support ticket.

SearchAdminAsync(AccountAdminQuery, CancellationToken)

Searches accounts for an operator, one page at a time.

Task<DatabaseResult<AccountAdminPage>> SearchAdminAsync(AccountAdminQuery query, CancellationToken cancellationToken = default)

Parameters

query AccountAdminQuery

The filter. Null is treated as an unfiltered first page.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<DatabaseResult<AccountAdminPage>>

One page of matching accounts, with the total for the pager.

Remarks

Returns AccountAdminData, which deliberately carries no SRP or TOTP material. See that type's remarks; do not "helpfully" widen it.

The text filter is a prefix match, and PageSize is clamped by the implementation. Both are deliberate: a search box is reachable by anyone who reaches the panel, and neither an unanchored pattern nor an unbounded page size gets to decide how much of the table one request reads.

UnbanAsync(string, CancellationToken)

Lifts a ban by restoring AccessLevel.Player.

Task<DatabaseResult> UnbanAsync(string accountName, CancellationToken cancellationToken = default)

Parameters

accountName string

Account to unban. Matched case-insensitively.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<DatabaseResult>

Success, or DB_NOT_FOUND when no such account exists.

Remarks

Deliberately not the inverse of BanAsync(string, DateTime?, string?, string?, CancellationToken). It restores the level and nothing else: the auth tokens and panel sessions the ban revoked are correctly gone, and reviving them would hand back credentials that may well be the reason for the ban and have since been shared or stolen. The player signs in again, which re-issues everything through the paths that are allowed to mint it.

It restores Player specifically, not whatever the level was before. This layer does not record the previous level, and guessing wrong in the upward direction would silently hand back operator access.