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