我一直在使用symfony 3创建Web应用程序,我已经使用EWZRecaptchaBundle向我的登录表单添加了Recaptcha,在登录之前如何添加监听器来验证Recaptcha的验证。在登录前添加监听器
<form method="post" action="{{ path('mysubmited') }}" id="form-validation" name="form-validation">
<div class="form-group form-input-icon form-input-icon-right">
<i class="icmn-spinner11 cat__core__spin"></i>
<div> {{ form_widget(form.username) }}</div>
</div>
<div class="form-group">
<div>{{ form_widget(form.password) }}</div>
</div>
<div class="offset-md-3 col-md-4">
{% form_theme form
'EWZRecaptchaBundle:Form:ewz_recaptcha_widget.html.twig' %}
{{ form_widget(form.recaptcha) }}
</div>
<div class="form-actions">
<button type="submit" class="btn btn-primary">Connexion</button>
<label class="ml-3">
<a href="#" class="swal-btn-lost-password"> Mot de passe oublié ?</a>
</label>
</div>
</form>
Security.yml
form_login:
check_path: /mysubmited
login_path: /login
username_parameter: "login_form[username]"
password_parameter: "login_form[password]"
#recaptcha_parameter: "login_form[recaptcha]"
csrf_parameter: "login_form[_token]"
csrf_token_id: a_private_string
provider: my_provider
default_target_path: homepage-auth
SecurityController.php
/**
* Login check action.
*
* @Route("/mysubmited", name="mysubmited")
* @throws \RuntimeException
*/
public function mysubmitedAction(Request $request)
{
throw new \RuntimeException('You must configure the check path to be handled by the firewall using form_login in your security firewall configuration.');
}
这位听众是在登录后,但我想在登录前验证Recaptcha的密钥。 –