♻️ Finish centerlizing the data models
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
namespace DysonNetwork.Pass.Permission;
|
||||
|
||||
using System;
|
||||
using DysonNetwork.Shared.Models;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class RequiredPermissionAttribute(string area, string key) : Attribute
|
||||
@@ -21,7 +22,7 @@ public class PermissionMiddleware(RequestDelegate next)
|
||||
|
||||
if (attr != null)
|
||||
{
|
||||
if (httpContext.Items["CurrentUser"] is not Account.Account currentUser)
|
||||
if (httpContext.Items["CurrentUser"] is not SnAccount currentUser)
|
||||
{
|
||||
httpContext.Response.StatusCode = StatusCodes.Status403Forbidden;
|
||||
await httpContext.Response.WriteAsync("Unauthorized");
|
||||
|
@@ -1,7 +1,6 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NodaTime;
|
||||
using System.Text.Json;
|
||||
using DysonNetwork.Pass;
|
||||
using DysonNetwork.Shared.Cache;
|
||||
using DysonNetwork.Shared.Models;
|
||||
|
||||
|
@@ -4,7 +4,6 @@ using DysonNetwork.Shared.Proto;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using System.Text.Json;
|
||||
using NodaTime.Serialization.Protobuf;
|
||||
using DysonNetwork.Shared.Models;
|
||||
|
||||
namespace DysonNetwork.Pass.Permission;
|
||||
|
||||
@@ -76,22 +75,3 @@ public class PermissionServiceGrpc(
|
||||
return new RemovePermissionNodeFromGroupResponse { Success = true };
|
||||
}
|
||||
}
|
||||
|
||||
public static class PermissionExtensions
|
||||
{
|
||||
public static DysonNetwork.Shared.Proto.PermissionNode ToProtoValue(this PermissionNode node)
|
||||
{
|
||||
return new DysonNetwork.Shared.Proto.PermissionNode
|
||||
{
|
||||
Id = node.Id.ToString(),
|
||||
Actor = node.Actor,
|
||||
Area = node.Area,
|
||||
Key = node.Key,
|
||||
Value = Value.Parser.ParseJson(node.Value.RootElement.GetRawText()),
|
||||
ExpiredAt = node.ExpiredAt?.ToTimestamp(),
|
||||
AffectedAt = node.AffectedAt?.ToTimestamp(),
|
||||
GroupId = node.GroupId?.ToString() ?? string.Empty
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user