Exemplo n.º 1
0
        public async Task <IActionResult> Login([FromBody] Credentials credentials, CancellationToken cancellationToken)
        {
            var checkResult = await _recaptchaService.VerifyAndCheckAsync(
                credentials.RecaptchaToken,
                _loginAction,
                cancellationToken);

            if (!checkResult.Success)
            {
                if (!checkResult.ScoreSatisfies)
                {
                    // Handle score less than specified threshold for v3
                    return(BadRequest());
                }

                if (!checkResult.Response.Success)
                {
                    // Handle unsuccessful verification response
                    _logger.LogError($"Recaptcha error: {JsonConvert.SerializeObject(checkResult.Response.ErrorCodes)}");
                }

                // Unsuccessful verification and check
                return(BadRequest());
            }

            // Process login

            return(Ok());
        }