mirror of
https://github.com/project-redbud/FunGame-Core.git
synced 2025-04-21 19:49:34 +08:00
添加2FA
This commit is contained in:
parent
0b272dd6b8
commit
0014ad4b33
33
Api/Utility/TFA.cs
Normal file
33
Api/Utility/TFA.cs
Normal file
@ -0,0 +1,33 @@
|
||||
namespace Milimoe.FunGame.Core.Api.Utility
|
||||
{
|
||||
/// <summary>
|
||||
/// aka 2FA
|
||||
/// </summary>
|
||||
public class TFA
|
||||
{
|
||||
private readonly Dictionary<string, string> TFACodes = new();
|
||||
|
||||
public virtual bool IsAvailable(string username)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public string GetTFACode(string username)
|
||||
{
|
||||
return TFACodes.ContainsKey(username) ? TFACodes[username] : Verification.CreateVerifyCode(Library.Constant.VerifyCodeType.MixVerifyCode, 5);
|
||||
}
|
||||
|
||||
public bool Authenticate(string username, string code)
|
||||
{
|
||||
if (!IsAvailable(username)) return false;
|
||||
if (TFACodes.ContainsKey(username) && TFACodes[username] == code)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user