2023-11-21 21:37:50 +01:00
|
|
|
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
|
2023-11-20 19:58:30 +01:00
|
|
|
|
2023-11-15 20:00:08 +01:00
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
2023-11-22 10:16:16 +01:00
|
|
|
using JetBrains.Annotations;
|
2023-11-15 20:00:08 +01:00
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
2023-10-12 09:15:34 +02:00
|
|
|
namespace Server.DB.Documents;
|
2023-08-10 10:47:35 +02:00
|
|
|
|
2023-11-19 17:07:28 +01:00
|
|
|
[Index(nameof(Username), IsUnique = true)]
|
|
|
|
[Index(nameof(Id), IsUnique = true)]
|
2023-08-14 13:49:27 +02:00
|
|
|
public class Account
|
2023-08-10 10:47:35 +02:00
|
|
|
{
|
2023-08-13 22:27:24 +02:00
|
|
|
public Account(string username, byte[] password, string email, byte permissionLevel, byte[] salt)
|
2023-08-10 10:47:35 +02:00
|
|
|
{
|
2023-11-19 17:07:28 +01:00
|
|
|
Username = username;
|
|
|
|
Password = password;
|
|
|
|
Email = email;
|
|
|
|
PermissionLevel = permissionLevel;
|
|
|
|
Salt = salt;
|
2023-08-10 10:47:35 +02:00
|
|
|
}
|
|
|
|
|
2023-11-15 20:00:08 +01:00
|
|
|
[Key]
|
|
|
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
2023-08-14 21:30:32 +02:00
|
|
|
public Guid Id { get; set; }
|
|
|
|
|
2023-11-22 07:59:08 +01:00
|
|
|
[MaxLength(20)] public string Username { get; set; }
|
2023-11-16 12:06:36 +01:00
|
|
|
|
2023-11-15 20:00:08 +01:00
|
|
|
[Column(TypeName = "bytea")] public byte[] Password { get; set; }
|
|
|
|
|
|
|
|
[EmailAddress] public string Email { get; set; }
|
2023-08-12 23:02:59 +02:00
|
|
|
public byte PermissionLevel { get; set; }
|
2023-11-15 20:00:08 +01:00
|
|
|
[Column(TypeName = "bytea")] public byte[] Salt { get; set; }
|
2023-11-22 07:59:08 +01:00
|
|
|
|
2023-11-22 10:16:16 +01:00
|
|
|
[CanBeNull] public virtual ICollection<Character> Characters { get; set; }
|
|
|
|
|
|
|
|
[DeleteBehavior(DeleteBehavior.Cascade)]
|
|
|
|
[CanBeNull]
|
|
|
|
public virtual GuildMember GuildMember { get; set; }
|
2023-08-11 11:31:30 +02:00
|
|
|
}
|