Table of Contents

Class AccountVerificationPolicy

Namespace
FishMMO.Server.Implementation
Assembly
FishMMO.Server.dll

Single source of truth for whether, and on which channels, new accounts must prove their contact details: the development-only AutoVerifyAccounts bypass and the per-channel VerifyEmail / VerifySms / VerifyDiscord switches. Which codes an account is then sent and asked for is AccountVerificationRules, shared with the Control Panel.

Two call sites must agree on these answers:

  • Account creation, which decides which codes to send and whether to verify the account outright.
  • The login lookup, which otherwise rejects an unverified account. Without the login side honouring the same switches, an account created before a switch changed would be asked for a code no server will ever send, or let in without one it still owes.

Precedence, highest first.

  1. AutoVerifyAccounts=true (editor and development builds only): every account is verified at creation and no code is sent.
  2. VerifyEmail / VerifySms / VerifyDiscord say which channels this server sends codes on. When all three are false, every new account is verified at creation through the same database write the bypass uses.
  3. Otherwise a code goes out on each channel the player chose that is switched on and the account can receive, falling back to email; any one code verifies the account, and there is no grace period: sign-in asks for a code until one is entered.

The compile-time guard on IsAutoVerifyEnabled(IServerConfiguration) is deliberate: a production player build ignores that key entirely, so a Development LoginServer.cfg that leaks into a production deployment cannot re-enable the bypass. Consequently the flag also has no effect in a server binary built with the Production working environment — build the server with the Development working environment for local testing. The channel switches have no such guard; a missing or unreadable value counts as true, so a typo verifies more, never less.

None of this decides two-factor. An authenticator is set up when the player opts in at registration, however the account was verified, on the game and the Control Panel alike.

public static class AccountVerificationPolicy
Inheritance
AccountVerificationPolicy
Inherited Members

Fields

AutoVerifyAccountsKey

Configuration key that enables the development email-verification bypass.

public const string AutoVerifyAccountsKey = "AutoVerifyAccounts"

Field Value

string

VerifyDiscordKey

Configuration key switching Discord-DM verification on or off. Default true.

public const string VerifyDiscordKey = "VerifyDiscord"

Field Value

string

VerifyEmailKey

Configuration key switching email-code verification on or off. Default true.

public const string VerifyEmailKey = "VerifyEmail"

Field Value

string

VerifySmsKey

Configuration key switching SMS-code verification on or off. Default true.

public const string VerifySmsKey = "VerifySms"

Field Value

string

Methods

EnabledChannels(IServerConfiguration)

The channels this server sends verification codes on.

public static AccountVerificationChannels EnabledChannels(IServerConfiguration configuration)

Parameters

configuration IServerConfiguration

Server configuration; null counts as every channel switched on.

Returns

AccountVerificationChannels

ExpireUndeliveredCodeAsync(IAccountService, string, int, AccountVerificationChannels, string)

Expires an email or SMS verification code that was stored but could not be queued for delivery, so the next sign-in issues a fresh one.

public static Task ExpireUndeliveredCodeAsync(IAccountService accountService, string accountName, int verifyCode, AccountVerificationChannels channel, string logSource)

Parameters

accountService IAccountService

Account service.

accountName string

Account whose code is retired.

verifyCode int

The code that was stored and not delivered.

channel AccountVerificationChannels

Which code: Email or Sms.

logSource string

Log source of the caller.

Returns

Task

Remarks

A code is stored before it is queued — the other order could deliver a code the database never held — and it is stored live for 24 hours. Sign-in re-issues a code only once the stored one has expired or is missing, and nothing else in the game re-issues one. So a code whose queue insert failed stayed live and undelivered for a day, and the player could not verify at all until it lapsed. Expiring that code now leaves nothing redeemable and makes the very next correct sign-in send a new one.

Best effort and bounded to one write: if it fails as well, the day's wait is what remains, and the log says so. The write is pinned to the code this server stored (IAccountService.ExpireVerifyCodeAsync), so a newer code another server issued in the meantime is left alone; it used to be an unconditional re-write that retired it.

IsAutoVerifyEnabled(IServerConfiguration)

Returns true when new accounts should be verified on creation and unverified accounts should be allowed to log in. Always false outside the editor and development builds.

public static bool IsAutoVerifyEnabled(IServerConfiguration configuration)

Parameters

configuration IServerConfiguration

Server configuration; a null configuration fails closed.

Returns

bool

IsDiscordVerificationEnabled(IServerConfiguration)

Whether a player who chose Discord verification must enter the code the Discord bot sent.

public static bool IsDiscordVerificationEnabled(IServerConfiguration configuration)

Parameters

configuration IServerConfiguration

Server configuration; null counts as switched on.

Returns

bool

Remarks

Needs FishMMO-DiscordBot running against the same database: it delivers the code.

IsEmailVerificationEnabled(IServerConfiguration)

Whether a player who chose email verification must enter an emailed code.

public static bool IsEmailVerificationEnabled(IServerConfiguration configuration)

Parameters

configuration IServerConfiguration

Server configuration; null counts as switched on.

Returns

bool

IsSmsCodeResendDue(DateTime?, DateTime)

Whether the sign-in path owes a fresh SMS verification code: none was ever issued (null), or the one on record has expired. Unlike the email resend, a missing code counts — SMS has no delivery-stamp grace period, so an account waiting on a code nobody sent would be stuck.

public static bool IsSmsCodeResendDue(DateTime? phoneVerifyCodeExpiresUtc, DateTime nowUtc)

Parameters

phoneVerifyCodeExpiresUtc DateTime?

The stored SMS code expiry, or null.

nowUtc DateTime

The current UTC time.

Returns

bool

IsSmsVerificationEnabled(IServerConfiguration)

Whether a player who chose SMS verification must enter a texted code.

public static bool IsSmsVerificationEnabled(IServerConfiguration configuration)

Parameters

configuration IServerConfiguration

Server configuration; null counts as switched on.

Returns

bool

TryReadBool(IServerConfiguration, string, out bool)

Reads a boolean key. IServerConfiguration has no boolean accessor, so every boolean in a .cfg is a string parsed here.

public static bool TryReadBool(IServerConfiguration configuration, string key, out bool value)

Parameters

configuration IServerConfiguration

Server configuration, or null.

key string

The key.

value bool

The parsed value; false when the method returns false.

Returns

bool

True only when the key is present and reads as true or false.