接口禁用

parent a6619e19
...@@ -38,6 +38,14 @@ public ActionsFilter(ILoggerFactory factory, IMemoryCache cache, IHostingEnviron ...@@ -38,6 +38,14 @@ public ActionsFilter(ILoggerFactory factory, IMemoryCache cache, IHostingEnviron
//记录Request请求 //记录Request请求
var kv = GetRequestContent(request); var kv = GetRequestContent(request);
_logger.LogInformation($"请求内容 {request.Method}:{JsonHelper.Serialize(kv)}"); _logger.LogInformation($"请求内容 {request.Method}:{JsonHelper.Serialize(kv)}");
//接口禁用
var disable = ((ControllerActionDescriptor)context.ActionDescriptor).MethodInfo.GetCustomAttributes(typeof(DisableAttribute), true);
if (disable.Length > 0)
{
var response = new ApiResponse(ResponseType.Disable, "接口已禁用");
context.Result = new ObjectResult(response);
return;
}
//token验证 //token验证
var arry = ((ControllerActionDescriptor)context.ActionDescriptor).MethodInfo.GetCustomAttributes(typeof(NoVerifyAttribute), true); var arry = ((ControllerActionDescriptor)context.ActionDescriptor).MethodInfo.GetCustomAttributes(typeof(NoVerifyAttribute), true);
if (arry.Length == 0) if (arry.Length == 0)
...@@ -50,20 +58,6 @@ public ActionsFilter(ILoggerFactory factory, IMemoryCache cache, IHostingEnviron ...@@ -50,20 +58,6 @@ public ActionsFilter(ILoggerFactory factory, IMemoryCache cache, IHostingEnviron
context.Result = new ObjectResult(response); context.Result = new ObjectResult(response);
return; return;
} }
//var activeuid = kv.GetValue<Nullable<int>>("activeuid");
//if (!activeuid.HasValue)
//{
// var response = new ApiResponse(ResponseType.TokenError, "Token无效");
// context.Result = new ObjectResult(response);
// return;
//}
}
var disable = ((ControllerActionDescriptor)context.ActionDescriptor).MethodInfo.GetCustomAttributes(typeof(DisableAttribute), true);
if (disable.Length > 0)
{
var response = new ApiResponse(ResponseType.Disable, "接口已禁用");
context.Result = new ObjectResult(response);
return;
} }
//验证请求参数 //验证请求参数
if (!context.ModelState.IsValid) if (!context.ModelState.IsValid)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment