无法访问symfony2中的app.user变量

时间:2014-07-23 08:25:39

标签: php symfony

我无法访问main中的app.user变量。但是,我可以访问管理部分中的变量。我试图谷歌它,发现它是由于防火墙问题。但是,我无法弄清楚问题所在。

Security.yml

防火墙

firewalls:
        admin_area:
            pattern:    ^/admin
            provider: admin_security
            anonymous: ~
            form_login:
                login_path:  /admin
                check_path:  /admin/login_check
                default_target_path: /admin/dashboard
                failure_path: /admin

            logout:
                path:   /admin/logout
                target: /admin

        company_area:
            pattern:    ^/
            anonymous: ~
            provider: company_security
            form_login:
                login_path:  /login
                default_target_path: /main/dashboard
                failure_path: /

            logout:
                path:   /main/logout
                target: /login

更新

登录检查脚本

if($encoder->isPasswordValid($client->getPassword(), $password, $client->getSalt()))
                    {
                        $token = new UsernamePasswordToken($username,$password, 'company_area', $client->getRoles());
                        $this->get('security.context')->setToken($token);
                        $this->get('session')->set('_security_company_area',serialize($token));

                        //now dispatch the login event

                        $event = new InteractiveLoginEvent($request, $token);
                        $this->get("event_dispatcher")->dispatch("security.interactive_login", $event);
                        //Now you can redirect where ever you need and the user will be logged in
                        return $this->redirect($this->generateURL('main_dashboard'));
                    }

0 个答案:

没有答案