From c4ed01214194413b52288886fc4ac843c55b56b9 Mon Sep 17 00:00:00 2001 From: milimoe Date: Tue, 17 Oct 2023 21:44:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0AuthenticationType=E5=92=8C?= =?UTF-8?q?=E4=BC=A0=E5=85=A5=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Library/Common/Architecture/Authenticator.cs | 17 +++++++++-------- Library/Constant/TypeEnum.cs | 8 ++++++++ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Library/Common/Architecture/Authenticator.cs b/Library/Common/Architecture/Authenticator.cs index 0858e3e..0fc52c7 100644 --- a/Library/Common/Architecture/Authenticator.cs +++ b/Library/Common/Architecture/Authenticator.cs @@ -1,5 +1,6 @@ using System.Data; using Milimoe.FunGame.Core.Api.Transmittal; +using Milimoe.FunGame.Core.Library.Constant; using Milimoe.FunGame.Core.Library.SQLScript.Entity; namespace Milimoe.FunGame.Core.Library.Common.Architecture @@ -13,13 +14,13 @@ namespace Milimoe.FunGame.Core.Library.Common.Architecture this.SQLHelper = SQLHelper; } - public abstract bool BeforeAuthenticator(); + public abstract bool BeforeAuthenticator(AuthenticationType type, params object[] args); - public abstract bool AfterAuthenticator(); + public abstract bool AfterAuthenticator(AuthenticationType type, params object[] args); public bool Authenticate(string script) { - if (!BeforeAuthenticator()) return false; + if (!BeforeAuthenticator(AuthenticationType.ScriptOnly, script)) return false; SQLHelper.ExecuteDataSet(script); if (SQLHelper.Success) { @@ -27,7 +28,7 @@ namespace Milimoe.FunGame.Core.Library.Common.Architecture if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { - if (!AfterAuthenticator()) return false; + if (!AfterAuthenticator(AuthenticationType.ScriptOnly, script)) return false; return true; } } @@ -36,7 +37,7 @@ namespace Milimoe.FunGame.Core.Library.Common.Architecture public bool Authenticate(string script, string column, T keyword) { - if (!BeforeAuthenticator()) return false; + if (!BeforeAuthenticator(AuthenticationType.Column, script, column)) return false; SQLHelper.ExecuteDataSet(script); if (SQLHelper.Success) { @@ -46,7 +47,7 @@ namespace Milimoe.FunGame.Core.Library.Common.Architecture ds.Tables[0].Rows.Count > 0 && ds.Tables[0].AsEnumerable().Where(row => row.Field(column)!.Equals(keyword)).Any()) { - if (!AfterAuthenticator()) return false; + if (!AfterAuthenticator(AuthenticationType.Column, script, column)) return false; return true; } } @@ -55,7 +56,7 @@ namespace Milimoe.FunGame.Core.Library.Common.Architecture public bool Authenticate(string username, string password) { - if (!BeforeAuthenticator()) return false; + if (!BeforeAuthenticator(AuthenticationType.Username, username, password)) return false; SQLHelper.ExecuteDataSet(UserQuery.Select_Users_LoginQuery(username, password)); if (SQLHelper.Success) { @@ -65,7 +66,7 @@ namespace Milimoe.FunGame.Core.Library.Common.Architecture ds.Tables[0].Columns.Contains(UserQuery.Column_Password) && ds.Tables[0].Rows.Count > 0) { - if (!AfterAuthenticator()) return false; + if (!AfterAuthenticator(AuthenticationType.Username, username, password)) return false; return true; } } diff --git a/Library/Constant/TypeEnum.cs b/Library/Constant/TypeEnum.cs index c84a214..fa2b3d0 100644 --- a/Library/Constant/TypeEnum.cs +++ b/Library/Constant/TypeEnum.cs @@ -293,4 +293,12 @@ namespace Milimoe.FunGame.Core.Library.Constant DuplicateEmail, InputVerifyCode } + + public enum AuthenticationType + { + None, + ScriptOnly, + Column, + Username + } }