Add more authenticators

This commit is contained in:
milimoe 2023-10-16 22:58:00 +08:00
parent c3c153635f
commit 6876430f7a
Signed by: milimoe
GPG Key ID: 05D280912DA6C69E

View File

@ -1,5 +1,7 @@
using System.Data; using System.Data;
using System.Data.Common;
using Milimoe.FunGame.Core.Api.Transmittal; using Milimoe.FunGame.Core.Api.Transmittal;
using Milimoe.FunGame.Core.Library.SQLScript.Entity;
namespace Milimoe.FunGame.Core.Library.Common.Architecture namespace Milimoe.FunGame.Core.Library.Common.Architecture
{ {
@ -12,6 +14,21 @@ namespace Milimoe.FunGame.Core.Library.Common.Architecture
this.SQLHelper = SQLHelper; 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<T>(string script, string column, T keyword) public bool Authenticate<T>(string script, string column, T keyword)
{ {
SQLHelper.ExecuteDataSet(script); SQLHelper.ExecuteDataSet(script);
@ -28,5 +45,23 @@ namespace Milimoe.FunGame.Core.Library.Common.Architecture
} }
return false; 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;
}
} }
} }