mirror of
https://github.com/project-redbud/FunGame-Server.git
synced 2025-04-20 19:19:39 +08:00
Authenticator 改动
This commit is contained in:
parent
6831114b62
commit
4cb82981c2
@ -1,44 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
30
FunGame.Server/Services/Authenticator.cs
Normal file
30
FunGame.Server/Services/Authenticator.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using Milimoe.FunGame.Core.Api.Transmittal;
|
||||
using Milimoe.FunGame.Core.Interface.Base;
|
||||
using Milimoe.FunGame.Core.Library.Constant;
|
||||
|
||||
namespace Milimoe.FunGame.Server.Services
|
||||
{
|
||||
public class Authenticator(IServerModel Server, SQLHelper SQLHelper, MailSender? MailSender) : Core.Library.Common.Architecture.Authenticator(SQLHelper)
|
||||
{
|
||||
public TFA TFA = new(SQLHelper);
|
||||
|
||||
private readonly IServerModel Server = Server;
|
||||
private readonly SQLHelper SQLHelper = SQLHelper;
|
||||
private readonly MailSender? MailSender = MailSender;
|
||||
|
||||
public override bool AfterAuthenticator(AuthenticationType type, params object[] args)
|
||||
{
|
||||
if (type == AuthenticationType.Username && args[0] is string username)
|
||||
{
|
||||
// 添加2FA二次验证等
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool BeforeAuthenticator(AuthenticationType type, params object[] args)
|
||||
{
|
||||
// 添加人机验证或频繁验证等
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,9 @@
|
||||
using Milimoe.FunGame.Core.Api.Utility;
|
||||
using Milimoe.FunGame.Core.Api.Transmittal;
|
||||
using Milimoe.FunGame.Core.Api.Utility;
|
||||
|
||||
namespace Milimoe.FunGame.Server.Services
|
||||
{
|
||||
public class TFA : TwoFactorAuthenticator
|
||||
public class TFA(SQLHelper SQLHelper) : TwoFactorAuthenticator(SQLHelper)
|
||||
{
|
||||
public override bool IsAvailable(string username)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user