async public Task RemoveSuspiciousUserAsync(string username) { var suspiciousUser = SuspiciousUser.FromString(await _cache.GetStringAsync(username)); if (suspiciousUser != null) { await _cache.RemoveAsync(username); } }
async public Task <bool> IsSuspiciousUserAsync(string username) { if (String.IsNullOrWhiteSpace(username)) { throw new ArgumentException("Username required"); } var suspiciousUser = SuspiciousUser.FromString(await _cache.GetStringAsync(username)); if (suspiciousUser != null) { var lastSet = suspiciousUser.TimeStamp.ToUniversalTime(); if ((DateTime.UtcNow - lastSet).TotalMinutes >= _options.RembemberSuspiciousUserTotalMinutes) { await RemoveSuspiciousUserAsync(username); return(false); } return(suspiciousUser.CountFailes >= _options.MaxFailCount); } return(false); }