Пример #1
0
        private async Task ChallengeWithRequestForRecaptcha(IOwinContext context, IOpenIdConnectRequest openIdConnectRequest, int numberOfFailedLogins)
        {
            var loginStatistics  = context.Get <ILoginStatistics>();
            var recaptchaMonitor = context.Get <IRecaptchaMonitor>();

            await loginStatistics.IncrementFailedLoginsForUserAndIpAddress(openIdConnectRequest.GetUsername(),
                                                                           openIdConnectRequest.GetRemoteIpAddress());

            await loginStatistics.IncrementChallengedLoginsForUserAndIpAddress(openIdConnectRequest.GetUsername(),
                                                                               openIdConnectRequest.GetRemoteIpAddress(), numberOfFailedLogins, _options.NumberOfAllowedLoginFailuresPerIpAddress);

            recaptchaMonitor?.ChallengeIssued(openIdConnectRequest.ToRecaptchaUserContext());

            var httpChallenge = context.Get <IHttpRecaptchaChallenge>();
            await httpChallenge.ReturnResponse(context, _options, openIdConnectRequest);
        }
        private async Task ChallengeWithRequestForRecaptcha(IOwinContext context, IOpenIdConnectRequest openIdConnectRequest)
        {
            var recaptchaMonitor = context.Get <IRecaptchaMonitor>();

            recaptchaMonitor?.ChallengeIssued(openIdConnectRequest.ToRecaptchaUserContext());

            var httpChallenge = context.Get <IHttpRecaptchaChallenge>();

            if (openIdConnectRequest == null)
            {
                await httpChallenge.ReturnResponse(context, _options);

                return;
            }

            await httpChallenge.ReturnResponse(context, _options, openIdConnectRequest);
        }