From 0014ad4b339c2f4b3e1a3619496ed2f508d122e0 Mon Sep 17 00:00:00 2001 From: milimoe Date: Tue, 17 Oct 2023 21:02:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A02FA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Api/Utility/TFA.cs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Api/Utility/TFA.cs diff --git a/Api/Utility/TFA.cs b/Api/Utility/TFA.cs new file mode 100644 index 0000000..8ba8cc7 --- /dev/null +++ b/Api/Utility/TFA.cs @@ -0,0 +1,33 @@ +namespace Milimoe.FunGame.Core.Api.Utility +{ + /// + /// aka 2FA + /// + public class TFA + { + private readonly Dictionary 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; + } + } + } +}