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; } }