mirror of
https://github.com/project-redbud/FunGame-Core.git
synced 2025-04-21 19:49:34 +08:00
添加AuthenticationType和传入参数
This commit is contained in:
parent
0014ad4b33
commit
c4ed012141
@ -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<T>(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<T>(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;
|
||||
}
|
||||
}
|
||||
|
@ -293,4 +293,12 @@ namespace Milimoe.FunGame.Core.Library.Constant
|
||||
DuplicateEmail,
|
||||
InputVerifyCode
|
||||
}
|
||||
|
||||
public enum AuthenticationType
|
||||
{
|
||||
None,
|
||||
ScriptOnly,
|
||||
Column,
|
||||
Username
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user