相关疑难解决方法(0)

Symfony2扩展了DefaultAuthenticationSuccessHandler

我想在身份验证成功后更改默认身份验证过程.我创建了一个在身份验证成功之后和重定向之前调用的服务.

namespace Pkr\BlogUserBundle\Handler;
use Doctrine\ORM\EntityManager;
use Pkr\BlogUserBundle\Service\Encoder\WpTransitionalEncoder;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
use Symfony\Component\Security\Http\Authentication\Response;

class AuthenticationSuccessHandler implements AuthenticationSuccessHandlerInterface
{

    protected $entityManager = null;
    protected $logger = null;
    protected $encoder = null;

    public function __construct(EntityManager $entityManager, LoggerInterface $logger, WpTransitionalEncoder $encoder)
    {
        $this->entityManager = $entityManager;
        $this->logger = $logger;
        $this->encoder = $encoder;
    }

    /**
    * This is called when an interactive authentication attempt succeeds. This
    * is called by authentication listeners inheriting from
    * AbstractAuthenticationListener.
    *
    * @param Request $request …
Run Code Online (Sandbox Code Playgroud)

security authentication extending symfony

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

symfony2如何在登录后重定向到请求的页面

假设我的路由/booking/(.*)security.yml中的防火墙配置保护,并且它需要" ROLE_USER ",当用户尝试访问前面带有 " / booking / "的任何路由时,app会将用户重定向到登录验证页面.

所以我的问题是,在用户提供他的凭据并获得身份验证后,Symfony 2如何能够将用户重定向回用户请求的页面/路由,或者Symfony 2存储该路由的位置是将其存储在某个会话中还是别的地方.

我们可以访问它吗?

symfony

19
推荐指数
3
解决办法
2万
查看次数

标签 统计

symfony ×2

authentication ×1

extending ×1

security ×1