Implemented roles and action timestamps. Added oermissions selector and interfaces
This commit was merged in pull request #3.
This commit is contained in:
12
Moonlight.Shared/Http/Requests/Roles/CreateRoleRequest.cs
Normal file
12
Moonlight.Shared/Http/Requests/Roles/CreateRoleRequest.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Moonlight.Shared.Http.Requests.Roles;
|
||||
|
||||
public class CreateRoleRequest
|
||||
{
|
||||
[Required] [MaxLength(15)] public string Name { get; set; }
|
||||
|
||||
[MaxLength(100)] public string Description { get; set; } = "";
|
||||
|
||||
[Required] public string[] Permissions { get; set; }
|
||||
}
|
||||
12
Moonlight.Shared/Http/Requests/Roles/UpdateRoleRequest.cs
Normal file
12
Moonlight.Shared/Http/Requests/Roles/UpdateRoleRequest.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Moonlight.Shared.Http.Requests.Roles;
|
||||
|
||||
public class UpdateRoleRequest
|
||||
{
|
||||
[Required] [MaxLength(15)] public string Name { get; set; }
|
||||
|
||||
[MaxLength(100)] public string Description { get; set; } = "";
|
||||
|
||||
[Required] public string[] Permissions { get; set; }
|
||||
}
|
||||
3
Moonlight.Shared/Http/Responses/Admin/RoleResponse.cs
Normal file
3
Moonlight.Shared/Http/Responses/Admin/RoleResponse.cs
Normal file
@@ -0,0 +1,3 @@
|
||||
namespace Moonlight.Shared.Http.Responses.Admin;
|
||||
|
||||
public record RoleResponse(int Id, string Name, string Description, string[] Permissions, int MemberCount, DateTimeOffset CreatedAt, DateTimeOffset UpdatedAt);
|
||||
@@ -1,3 +1,3 @@
|
||||
namespace Moonlight.Shared.Http.Responses.Users;
|
||||
|
||||
public record UserResponse(int Id, string Username, string Email);
|
||||
public record UserResponse(int Id, string Username, string Email, DateTimeOffset CreatedAt, DateTimeOffset UpdatedAt);
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using Moonlight.Shared.Http.Requests.Roles;
|
||||
using Moonlight.Shared.Http.Requests.Users;
|
||||
using Moonlight.Shared.Http.Responses;
|
||||
using Moonlight.Shared.Http.Responses.Admin;
|
||||
@@ -15,6 +16,10 @@ namespace Moonlight.Shared.Http;
|
||||
[JsonSerializable(typeof(UserResponse))]
|
||||
[JsonSerializable(typeof(SystemInfoResponse))]
|
||||
[JsonSerializable(typeof(PagedData<UserResponse>))]
|
||||
[JsonSerializable(typeof(PagedData<RoleResponse>))]
|
||||
[JsonSerializable(typeof(RoleResponse))]
|
||||
[JsonSerializable(typeof(CreateRoleRequest))]
|
||||
[JsonSerializable(typeof(UpdateRoleRequest))]
|
||||
public partial class SerializationContext : JsonSerializerContext
|
||||
{
|
||||
}
|
||||
20
Moonlight.Shared/Permissions.cs
Normal file
20
Moonlight.Shared/Permissions.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
namespace Moonlight.Shared;
|
||||
|
||||
public static class Permissions
|
||||
{
|
||||
public const string Prefix = "Permissions:";
|
||||
public const string ClaimType = "Permissions";
|
||||
|
||||
public static class Admin
|
||||
{
|
||||
public static class Users
|
||||
{
|
||||
private const string Section = "Users";
|
||||
|
||||
public const string View = $"{Prefix}{Section}.View";
|
||||
public const string Edit = $"{Prefix}{Section}.Edit";
|
||||
public const string Create = $"{Prefix}{Section}.Create";
|
||||
public const string Delete = $"{Prefix}{Section}.Delete";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user