Пример #1
0
        public async Task <Status> UpdatePasswordHashFailureCountAsync(string uniqueIdentifier, int failureCount)
        {
            _logger.LogTrace("Update password hash failure count");
            var count  = 0;
            var record = await _context.PasswordHashes.FindAsync(uniqueIdentifier);

            if (record != null)
            {
                record.FailedAttemptCount = failureCount;
                _context.Entry(record).Property(x => x.Hash).IsModified             = false;
                _context.Entry(record).Property(x => x.LastChangedUTC).IsModified   = false;
                _context.Entry(record).Property(x => x.TempLockUntilUTC).IsModified = false;
                count = await _context.SaveChangesAsync();
            }
            if (count == 0)
            {
                return(Status.Error(_localizer["Password failure count not updated."]));
            }

            return(Status.Success(_localizer["Password failure count updated."]));
        }
Пример #2
0
        public async Task <Status> UpdateOneTimeCodeSentCountAsync(string sentTo, int sentCount, string newRedirectUrl = null)
        {
            _logger.LogTrace("Update one time code sent count to {0}", sentCount);
            var count  = 0;
            var record = await _context.OneTimeCodes.FindAsync(sentTo);

            if (record != null)
            {
                record.SentCount = sentCount;
                _context.Entry(record).Property(x => x.FailedAttemptCount).IsModified = false;
                _context.Entry(record).Property(x => x.ExpiresUTC).IsModified         = false;
                _context.Entry(record).Property(x => x.LongCode).IsModified           = false;
                _context.Entry(record).Property(x => x.ShortCode).IsModified          = false;
                _context.Entry(record).Property(x => x.ClientNonceHash).IsModified    = false;
                if (newRedirectUrl != null)
                {
                    record.RedirectUrl = newRedirectUrl;
                }
                else
                {
                    _context.Entry(record).Property(x => x.RedirectUrl).IsModified = false;
                }
                count = await _context.SaveChangesAsync();
            }
            if (count == 0)
            {
                return(Status.Error(_localizer["One time code sent count was not updated."]));
            }

            return(Status.Success(_localizer["One time code sent count was updated."]));
        }