相关疑难解决方法(0)

是否存在任何类型的"登录前"事件或类似事件?

我需要在检查用户的凭据是否正确之前运行一些代码.目前,我正在通过触发事件的自定义事件侦听器实现此目的,kernel.request并检查请求的URL是否与security.yml的check_path设置匹配.但这是低效的,因为它运行在每个请求上.我知道这个onSecurityInteractiveLogin事件,但我相信在成功登录尝试后会发生火灾.有谁知道是否有预登录事件,或者我可以自己发送自定义事件?

php symfony

10
推荐指数
1
解决办法
3700
查看次数

添加验证码到 Symfony2 登录

我需要将验证码添加到我的登录页面,我正在使用 GregwarCaptchaBundle 和 FosUserBundle。

目前我已经使用以下代码在登录时显示验证码:

<?php

/*
 * This file is part of the FOSUserBundle package.
 *
 * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace FOS\UserBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Security\Core\SecurityContextInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Gregwar\Captcha\CaptchaBuilder;

class SecurityController extends Controller
{
    public function loginAction(Request $request)
    {
        $builtCaptcha = new CaptchaBuilder();
        $builtCaptcha->build();
        $builtCaptcha->save('captcha.jpg');
        /** @var $session \Symfony\Component\HttpFoundation\Session\Session */
        $session …
Run Code Online (Sandbox Code Playgroud)

php authentication validation captcha symfony

2
推荐指数
1
解决办法
2954
查看次数

标签 统计

php ×2

symfony ×2

authentication ×1

captcha ×1

validation ×1