From 6876430f7a4811b9c849c838b5f9d4befb8cf194 Mon Sep 17 00:00:00 2001 From: milimoe Date: Mon, 16 Oct 2023 22:58:00 +0800 Subject: [PATCH] Add more authenticators --- Library/Common/Architecture/Authenticator.cs | 35 ++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Library/Common/Architecture/Authenticator.cs b/Library/Common/Architecture/Authenticator.cs index 6610290..c80d709 100644 --- a/Library/Common/Architecture/Authenticator.cs +++ b/Library/Common/Architecture/Authenticator.cs @@ -1,5 +1,7 @@ using System.Data; +using System.Data.Common; using Milimoe.FunGame.Core.Api.Transmittal; +using Milimoe.FunGame.Core.Library.SQLScript.Entity; namespace Milimoe.FunGame.Core.Library.Common.Architecture { @@ -12,6 +14,21 @@ namespace Milimoe.FunGame.Core.Library.Common.Architecture this.SQLHelper = SQLHelper; } + public bool Authenticate(string script) + { + SQLHelper.ExecuteDataSet(script); + if (SQLHelper.Success) + { + DataSet ds = SQLHelper.DataSet; + if (ds.Tables.Count > 0 && + ds.Tables[0].Rows.Count > 0) + { + return true; + } + } + return false; + } + public bool Authenticate(string script, string column, T keyword) { SQLHelper.ExecuteDataSet(script); @@ -28,5 +45,23 @@ namespace Milimoe.FunGame.Core.Library.Common.Architecture } return false; } + + public bool Authenticate(string script, string username, string password) + { + SQLHelper.ExecuteDataSet(script); + 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()) + { + return true; + } + } + return false; + } } }