api
This commit is contained in:
@@ -12,11 +12,32 @@ public sealed class Account
|
||||
public byte[] PasswordSalt { get; set; } = Array.Empty<byte>();
|
||||
public bool IsBanned { get; set; }
|
||||
public DateTime? BannedUntil { get; set; }
|
||||
|
||||
// Role-based access
|
||||
public AccountRole Role { get; set; } = AccountRole.Player;
|
||||
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public DateTime UpdatedAt { get; set; }
|
||||
|
||||
public ICollection<Session> Sessions { get; set; } = new List<Session>();
|
||||
public ICollection<Character> Characters { get; set; } = new List<Character>();
|
||||
|
||||
// Helper methods
|
||||
public bool IsAdmin => Role == AccountRole.Admin || Role == AccountRole.SuperAdmin;
|
||||
public bool IsModerator => Role >= AccountRole.Moderator;
|
||||
public bool IsSuperAdmin => Role == AccountRole.SuperAdmin;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Account roles with increasing privilege levels
|
||||
/// </summary>
|
||||
public enum AccountRole
|
||||
{
|
||||
Player = 0, // Default - normal player
|
||||
Vip = 10, // VIP player (cosmetics, queue priority, etc.)
|
||||
Moderator = 50, // Can mute/kick players, view reports
|
||||
Admin = 90, // Can manage items, view stats, ban players
|
||||
SuperAdmin = 100 // Full access - can promote/demote admins
|
||||
}
|
||||
|
||||
public sealed class AccountConfig : IEntityTypeConfiguration<Account>
|
||||
@@ -32,6 +53,7 @@ public sealed class AccountConfig : IEntityTypeConfiguration<Account>
|
||||
e.HasIndex(x => x.Email).IsUnique();
|
||||
e.Property(x => x.PasswordHash).HasColumnType("varbinary(64)");
|
||||
e.Property(x => x.PasswordSalt).HasColumnType("varbinary(32)");
|
||||
e.Property(x => x.Role).HasDefaultValue(AccountRole.Player);
|
||||
e.Property(x => x.CreatedAt).HasDefaultValueSql("CURRENT_TIMESTAMP(6)");
|
||||
e.Property(x => x.UpdatedAt).HasDefaultValueSql("CURRENT_TIMESTAMP(6)")
|
||||
.ValueGeneratedOnAddOrUpdate();
|
||||
|
||||
Reference in New Issue
Block a user