23 lines
628 B
C#
23 lines
628 B
C#
|
namespace Myhm.Data;
|
||
|
|
||
|
public class User
|
||
|
{
|
||
|
public int Id { get; set; }
|
||
|
public string Token { get; set; } = default!;
|
||
|
public int DiscordUserId { get; set; }
|
||
|
public DateTime CreatedAt { get; set; }
|
||
|
public bool WriteAccess { get; set; } = false;
|
||
|
public bool Disabled { get; set; } = false;
|
||
|
|
||
|
public static User FromToken(string token, MyhmContext context)
|
||
|
{
|
||
|
User user =
|
||
|
context.User.First(u => u.Token == token) ?? throw new Exception("User not found");
|
||
|
if (user.Disabled)
|
||
|
{
|
||
|
throw new Exception("User not found");
|
||
|
}
|
||
|
return user;
|
||
|
}
|
||
|
}
|