milimoe 14ff58f4f4
为服务器统一数据访问连接 (#37)
* 添加 Web API 和 RESTful API 模式;
* 添加 SQLite 模式;
* 添加 ISocketMessageProcessor 和 ISocketListener<> 接口,用于统一数据访问;
* 重做了 ISocketModel;
* 完善了 WebSocket 的连接模式。
2024-10-04 12:39:15 +08:00

45 lines
1.4 KiB
C#

using Milimoe.FunGame.Core.Api.Transmittal;
using Milimoe.FunGame.Core.Api.Utility;
using Milimoe.FunGame.Core.Interface.Base;
using Milimoe.FunGame.Core.Library.Constant;
namespace Milimoe.FunGame.Server.Controller
{
public class Authenticator : Core.Library.Common.Architecture.Authenticator
{
public TwoFactorAuthenticator Login2FA = new();
private readonly IServerModel Server;
private readonly SQLHelper SQLHelper;
private readonly MailSender? MailSender;
public Authenticator(IServerModel Server, SQLHelper SQLHelper, MailSender? MailSender) : base(SQLHelper)
{
this.Server = Server;
this.SQLHelper = SQLHelper;
this.MailSender = MailSender;
}
public override bool AfterAuthenticator(AuthenticationType type, params object[] args)
{
if (type == AuthenticationType.Username)
{
// 添加2FA二次验证等
string username = (string)args[0];
}
return true;
}
public override bool BeforeAuthenticator(AuthenticationType type, params object[] args)
{
// 添加人机验证或频繁验证等
return true;
}
public bool Check2FA(string username, string code)
{
return Login2FA.Authenticate(username, code);
}
}
}