AuthorBuddy/Data/UserEntity.cs

31 lines
822 B
C#
Raw Normal View History

2026-06-21 07:52:03 +02:00
using LiteDB;
2026-05-17 07:27:18 +02:00
namespace AuthorBuddy.Web.Data;
2026-05-25 06:38:16 +02:00
public enum UserRole
{
Author,
2026-06-21 07:52:03 +02:00
Administrator,
Blogger,
Chat
2026-05-25 06:38:16 +02:00
}
2026-05-17 07:27:18 +02:00
public class UserEntity
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
2026-06-21 07:52:03 +02:00
public string Email { get; set; } = string.Empty;
2026-05-21 11:04:42 +02:00
public string PasswordHash { get; set; } = string.Empty;
public string TwoFactorSecret { get; set; } = string.Empty;
public bool TwoFactorEnabled { get; set; }
2026-06-21 07:52:03 +02:00
public List<UserRole> Roles { get; set; } = new() { UserRole.Author };
2026-05-25 06:38:16 +02:00
public bool IsActive { get; set; } = true;
2026-06-21 07:52:03 +02:00
[BsonIgnore]
public bool IsAdministrator => Roles.Contains(UserRole.Administrator);
public bool HasRole(UserRole role) => Roles.Contains(role);
public bool HasAnyRole(params UserRole[] roles) => roles.Any(HasRole);
2026-05-17 07:27:18 +02:00
}