【发布时间】:2013-01-01 02:00:36
【问题描述】:
基于这个问题:Automatic post-registration user authentication
$token = new UsernamePasswordToken($userEntity, null, 'main', array('ROLE_USER'));
$this->get('security.context')->setToken($token);
这在 Symfony 2 上运行良好,但在 Symfony 2.1 的实际版本中,这个接缝不再起作用,我尝试相同的代码但没有成功(也没有错误)。这个想法是在不使用登录表单的情况下通过 ajax 对我的用户进行身份验证。这是因为我使用这个架构:
if(user_on_data_base) {
if(user_fb_linked_with_us) { // authenticate him and redirect to /home }
}
这是通过 ajax 执行的。
编辑: 最奇怪的是,如果我从用户控制器执行此代码,它就可以工作!但不要从我的 ajax 控制器执行它。
【问题讨论】:
标签: symfony symfony-2.1