From a0b5e92db5f73b7983c062d3a6a8a831e6d46025 Mon Sep 17 00:00:00 2001 From: ky_sunl Date: Fri, 19 Mar 2021 03:13:31 +0000 Subject: [PATCH] --- .../Authorized/AuthorizedHelper.cs | 15 +++++++++++++++ .../Ewide.Core.WebApi/App_Start/WebApiConfig.cs | 2 ++ .../Areas/Base/Controllers/GateController.cs | 8 ++++++-- .../Controllers/Code/ValidateArgumentsFilter.cs | 1 + 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Api/Ewide.Core/Ewide.Core.Common/Authorized/AuthorizedHelper.cs b/Api/Ewide.Core/Ewide.Core.Common/Authorized/AuthorizedHelper.cs index 9ea2811..e5b242c 100644 --- a/Api/Ewide.Core/Ewide.Core.Common/Authorized/AuthorizedHelper.cs +++ b/Api/Ewide.Core/Ewide.Core.Common/Authorized/AuthorizedHelper.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.IdentityModel.Tokens.Jwt; using System.Linq; using System.Security.Claims; +using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; using System.Web; @@ -201,5 +202,19 @@ namespace Ewide.Core.Common { UpdateWhiteListUser(userID); } + + public static string GetPasswordMD5(string password) + { + var str = password.Trim().ToLower(); + + str = BitConverter.ToString(new MD5CryptoServiceProvider().ComputeHash(UTF8Encoding.Default.GetBytes(str))).Replace("-", ""); + + return str; + } + + public static bool IsAuthorized() + { + return false; + } } } diff --git a/Api/Ewide.Core/Ewide.Core.WebApi/App_Start/WebApiConfig.cs b/Api/Ewide.Core/Ewide.Core.WebApi/App_Start/WebApiConfig.cs index 2ab242e..57bc177 100644 --- a/Api/Ewide.Core/Ewide.Core.WebApi/App_Start/WebApiConfig.cs +++ b/Api/Ewide.Core/Ewide.Core.WebApi/App_Start/WebApiConfig.cs @@ -31,6 +31,8 @@ namespace Ewide.Core.WebApi // 500 config.Services.Replace(typeof(IHttpActionInvoker), new HttpWebApiControllerActionInvoker(config)); #endregion + + config.Filters.Add(new ValidateArgumentsFilter()); } } } diff --git a/Api/Ewide.Core/Ewide.Core.WebApi/Areas/Base/Controllers/GateController.cs b/Api/Ewide.Core/Ewide.Core.WebApi/Areas/Base/Controllers/GateController.cs index 8b82431..41ca0d4 100644 --- a/Api/Ewide.Core/Ewide.Core.WebApi/Areas/Base/Controllers/GateController.cs +++ b/Api/Ewide.Core/Ewide.Core.WebApi/Areas/Base/Controllers/GateController.cs @@ -8,7 +8,6 @@ using System.Web.Http; namespace Ewide.Core.WebApi.Areas.Base.Controllers { - [ValidateArgumentsFilter] public class GateController : BaseController { /// @@ -16,10 +15,15 @@ namespace Ewide.Core.WebApi.Areas.Base.Controllers /// /// /// - [ValidateArgumentsFilter(AllowNull = true)] public IHttpActionResult Login(LoginDTO dto) { return DisplayJSON(dto); } + + [ValidateArgumentsFilter(AllowNull = true)] + public IHttpActionResult AllowNullAPI(LoginDTO dto) + { + return DisplayJSON(dto); + } } } diff --git a/Api/Ewide.Core/Ewide.Core.WebApi/Controllers/Code/ValidateArgumentsFilter.cs b/Api/Ewide.Core/Ewide.Core.WebApi/Controllers/Code/ValidateArgumentsFilter.cs index d955404..c93e493 100644 --- a/Api/Ewide.Core/Ewide.Core.WebApi/Controllers/Code/ValidateArgumentsFilter.cs +++ b/Api/Ewide.Core/Ewide.Core.WebApi/Controllers/Code/ValidateArgumentsFilter.cs @@ -11,6 +11,7 @@ using System.Web.Http.Filters; namespace Ewide.Core.WebApi { + [AttributeUsage(AttributeTargets.All, AllowMultiple = false)] public class ValidateArgumentsFilter : ActionFilterAttribute { public bool AllowNull { get; set; } = false;