mirror of
https://github.com/DorkSquadRR/DorkNet.git
synced 2026-10-26 07:28:45 -07:00
11377b46d5
Port the December signup-code feature to the 2020.03 branch. While account creation is disabled, the only way in is now an admin-issued single-use signup code, redeemed on the public site's /join page. Because the 2020.03 watch login is device-id-bound with no code field, a new device refused at the signups-disabled gate (PlatformLogin / account create) is stashed in a PendingDevices table keyed by the real client IP (CF-Connecting-IP aware). The /join page shows the player the device their own client just reported; they enter code + username and the account is minted bound to that device, so the next launch logs straight in. No watch changes. - SignupCodeEntity + PendingDeviceEntity; tables created via idempotent CREATE TABLE IF NOT EXISTS at boot (Program.cs Postgres patch block + SQLite path) since they post-date the migration chain. - SignupCodeService: generate / list / revoke / redeem + pending-device capture (single-use, expiry, revoke validation). - Admin: GET/POST signup-codes + revoke endpoints and a Signup codes admin-ui page (generate with descriptor/expiry, status table, revoke). - Public: anonymous /api/site/v1/join pending-devices + redeem, and a /join site page (+ header link). - README documents the flow.
41 lines
1.7 KiB
C#
41 lines
1.7 KiB
C#
namespace DorkNet.Server.Data.Entities;
|
|
|
|
/// <summary>
|
|
/// An admin-issued, single-use signup code (Discord-invite style). While
|
|
/// the server has signups disabled, the only way to mint a new account is
|
|
/// to redeem one of these on the public site's <c>/join</c> page. Each
|
|
/// code carries a free-text <see cref="Descriptor"/> so admins can track
|
|
/// who they handed it to, an optional <see cref="ExpiresAt"/>, and the
|
|
/// redemption result (<see cref="RedeemedByPlayerId"/> /
|
|
/// <see cref="RedeemedAt"/>). Codes can be revoked before use.
|
|
/// </summary>
|
|
public class SignupCodeEntity
|
|
{
|
|
public long Id { get; set; }
|
|
|
|
/// <summary>The opaque code string the player types on /join.
|
|
/// Uppercase, hyphenated, unambiguous alphabet (no 0/O/1/I).</summary>
|
|
public string Code { get; set; } = string.Empty;
|
|
|
|
/// <summary>Free-text note for the admin — "who is this for". Shown
|
|
/// only in the admin panel, never to the redeemer.</summary>
|
|
public string Descriptor { get; set; } = string.Empty;
|
|
|
|
/// <summary>Player id of the admin who generated the code (0 if
|
|
/// generated by a system/CLI path).</summary>
|
|
public long CreatedByPlayerId { get; set; }
|
|
|
|
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
|
|
|
/// <summary>Optional hard expiry. Null = never expires.</summary>
|
|
public DateTime? ExpiresAt { get; set; }
|
|
|
|
/// <summary>Set once the code is redeemed; null while unused.</summary>
|
|
public long? RedeemedByPlayerId { get; set; }
|
|
public DateTime? RedeemedAt { get; set; }
|
|
|
|
/// <summary>Admin kill switch — a revoked code can never be redeemed,
|
|
/// even if otherwise valid.</summary>
|
|
public bool Revoked { get; set; }
|
|
}
|