mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
feat(roles, visibility): refactor user roles to use flags and introduce visibility enum
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SharpbinV3.Server.Data.Enums;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace SharpbinV3.Server.Data.Entities
|
||||
@@ -33,7 +34,7 @@ namespace SharpbinV3.Server.Data.Entities
|
||||
|
||||
public int Views { get; set; }
|
||||
public string? Syntax { get; set; }
|
||||
public int Visibility { get; set; } = 0; // 0 = public, 1 = unlisted, 2 = private (encrypted pastes handled on frontend)
|
||||
public Visibility Visibility { get; set; } = Visibility.Public;
|
||||
|
||||
public long ExpiresAt { get; set; } // timestamp of when the paste expires, or 0 for never
|
||||
|
||||
|
||||
@@ -1,8 +1,18 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SharpbinV3.Server.Data.Enums;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace SharpbinV3.Server.Data.Entities
|
||||
{
|
||||
|
||||
[Flags]
|
||||
public enum Role
|
||||
{
|
||||
User = 1,
|
||||
Moderator = 2,
|
||||
Admin = 4
|
||||
}
|
||||
|
||||
[Index(nameof(UID))]
|
||||
[Index(nameof(UUID), IsUnique = true)]
|
||||
public sealed class User
|
||||
@@ -20,8 +30,10 @@ namespace SharpbinV3.Server.Data.Entities
|
||||
public string? DisplayName { get; set; }
|
||||
public long? LastLogin { get; set; }
|
||||
|
||||
public int[] Roles { get; set; } = [0]; // 0 = regular user, 1 = moderator, 255 = admin
|
||||
public int Visibility { get; set; } = 0; // 0 = public, 1 = unlisted, 2 = private
|
||||
public Role Roles { get; set; } = Role.User;
|
||||
public bool IsBanned { get; set; } = false;
|
||||
|
||||
public Visibility Visibility { get; set; } = Visibility.Public;
|
||||
public List<Paste> Pastes { get; set; } = [];
|
||||
public List<RefreshToken> RefreshTokens { get; set; } = [];
|
||||
public List<Report> Reports { get; set; } = [];
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace SharpbinV3.Server.Data.Enums
|
||||
{
|
||||
public enum Visibility
|
||||
{
|
||||
Public = 0,
|
||||
Unlisted = 1,
|
||||
Private = 2
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user