From 0b272dd6b8c38afbc6c3935f23fca15eca377a6d Mon Sep 17 00:00:00 2001 From: milimoe Date: Tue, 17 Oct 2023 20:31:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0before&after?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Library/Common/Architecture/Authenticator.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Library/Common/Architecture/Authenticator.cs b/Library/Common/Architecture/Authenticator.cs index c80d709..0858e3e 100644 --- a/Library/Common/Architecture/Authenticator.cs +++ b/Library/Common/Architecture/Authenticator.cs @@ -1,5 +1,4 @@ using System.Data; -using System.Data.Common; using Milimoe.FunGame.Core.Api.Transmittal; using Milimoe.FunGame.Core.Library.SQLScript.Entity; @@ -14,8 +13,13 @@ namespace Milimoe.FunGame.Core.Library.Common.Architecture this.SQLHelper = SQLHelper; } + public abstract bool BeforeAuthenticator(); + + public abstract bool AfterAuthenticator(); + public bool Authenticate(string script) { + if (!BeforeAuthenticator()) return false; SQLHelper.ExecuteDataSet(script); if (SQLHelper.Success) { @@ -23,6 +27,7 @@ namespace Milimoe.FunGame.Core.Library.Common.Architecture if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { + if (!AfterAuthenticator()) return false; return true; } } @@ -31,6 +36,7 @@ namespace Milimoe.FunGame.Core.Library.Common.Architecture public bool Authenticate(string script, string column, T keyword) { + if (!BeforeAuthenticator()) return false; SQLHelper.ExecuteDataSet(script); if (SQLHelper.Success) { @@ -40,24 +46,26 @@ 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; return true; } } return false; } - public bool Authenticate(string script, string username, string password) + public bool Authenticate(string username, string password) { - SQLHelper.ExecuteDataSet(script); + if (!BeforeAuthenticator()) return false; + SQLHelper.ExecuteDataSet(UserQuery.Select_Users_LoginQuery(username, password)); if (SQLHelper.Success) { DataSet ds = SQLHelper.DataSet; if (ds.Tables.Count > 0 && ds.Tables[0].Columns.Contains(UserQuery.Column_Username) && ds.Tables[0].Columns.Contains(UserQuery.Column_Password) && - ds.Tables[0].Rows.Count > 0 && - ds.Tables[0].AsEnumerable().Where(row => (string)row[UserQuery.Column_Username] == username && (string)row[UserQuery.Column_Password] == password).Any()) + ds.Tables[0].Rows.Count > 0) { + if (!AfterAuthenticator()) return false; return true; } }