public static void AddVerificationCode(string email, string code) { foreach (var item in VerificationDict.Where(kvp => kvp.Value.TimeStamp < DateTime.Now.AddMinutes(-verificationCodeTimeLimit)).ToList()) { VerificationDict.Remove(item.Key); } VerificationDict[email] = new TimedCode(code); }
public static void AddTimedCode(string userg) { var tc = GetMostRecentCode(userg); if (tc == null) { tc = new TimedCode(userg); PresentationCode.Add(tc); } else { tc.TimeStamp = DateTime.Now; } }
public static bool TryGetVerificationCode(string email, out string code) { code = null; TimedCode vcode = null; if (VerificationDict.TryGetValue(email, out vcode)) { if (vcode.TimeStamp > DateTime.Now.AddMinutes(-verificationCodeTimeLimit)) { code = vcode.Code; return(true); } } return(false); }