protected virtual void CleanupExpiredTokens() { foreach (var challenge in _activeChallenges) { DateTime temp; if (DateTime.UtcNow > challenge.Value) { bool removed = _activeChallenges.TryRemove(challenge.Key, out temp); if (removed) { _logger.ChallengeExpired(challenge.Key); } } } }
protected virtual void CleanupExpiredTokens() { using (new SecurityDisabler()) { var challenges = RootItem.GetChildren(); foreach (Item challenge in challenges) { // if the value in the field is not a valid long (ticks) value, or the value is valid but too old, we kill it if (!long.TryParse(challenge["Expires"], out var expiresTicks) || expiresTicks < DateTime.UtcNow.Ticks) { // challenge name starts with 'AUTH' _challengeStoreLogger?.ChallengeExpired(challenge.Name.Substring(4)); challenge.Delete(); } } } }