Exemplo n.º 1
0
        /// <summary>
        /// Records that a failed access has occurred, incrementing the failed access count.
        /// </summary>
        /// <param name="user">The user whose cancellation count should be incremented.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
        /// <returns>The <see cref="Task"/> that represents the asynchronous operation, containing the incremented failed access count.</returns>
        public async Task <int> IncrementAccessFailedCountAsync(TUser user, CancellationToken cancellationToken)
        {
            ThrowIfDisposed();
            cancellationToken.ThrowIfCancellationRequested();
            log.LogDebug("IncrementAccessFailedCountAsync");

            if (user == null)
            {
                throw new ArgumentNullException("user");
            }

            user.AccessFailedCount += 1;
            cancellationToken.ThrowIfCancellationRequested();
            await commands.UpdateFailedPasswordAttemptCount(user.SiteId, user.Id, user.AccessFailedCount, cancellationToken);

            return(user.AccessFailedCount);
        }