2024-11-01 16:45:39 +08:00
|
|
|
|
using LFlow.Base.Utils;
|
|
|
|
|
|
using LFlow.Middleware;
|
|
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
|
using Microsoft.AspNetCore.Routing;
|
|
|
|
|
|
using Newtonsoft.Json;
|
2024-10-31 10:38:21 +08:00
|
|
|
|
using Serilog;
|
|
|
|
|
|
|
|
|
|
|
|
namespace LFlow.UserManagement
|
|
|
|
|
|
{
|
2024-11-01 16:45:39 +08:00
|
|
|
|
public class UserMiddleware(ILogger logger) : ILFlowMiddleware
|
2024-10-31 10:38:21 +08:00
|
|
|
|
{
|
|
|
|
|
|
public int Priority => 1;
|
|
|
|
|
|
public async Task RunAsync(Microsoft.AspNetCore.Http.HttpContext context, Func<Task> next)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Do something before
|
2024-11-01 16:45:39 +08:00
|
|
|
|
var progController = context.GetRouteData()?.Values["controller"]?.ToString();
|
|
|
|
|
|
var progAction = context.GetRouteData()?.Values["action"]?.ToString();
|
|
|
|
|
|
if (progAction != "ListAll")
|
|
|
|
|
|
await next();
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
await context.Response.WriteAsync(JsonConvert.SerializeObject(ApiResult<object>.FailResult("无权限!", 100501)));
|
|
|
|
|
|
}
|
2024-10-31 10:38:21 +08:00
|
|
|
|
// Do something after
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|