symfony2:两个身份验证提供程序

时间:2014-06-24 09:31:35

标签: php symfony authentication

我有两个单独的身份验证表单。一个用于管理员,另一个用于用户。但是,当我从两个登录页面进行身份验证时,它都由AdminUser Repository处理。在客户端身份验证的情况下,它应该由User处理。它不会发生。我在配置中缺少什么???

如果我没有在默认的orm中添加ESSUserBundle,我也会收到此错误。

致命错误:未捕获的异常' Doctrine \ ORM \ ORMException'使用消息'未知实体名称空间别名' ESSUserBundle'。'在第236行的D:\ xampp \ htdocs \ essweb \ vendor \ doctrine \ orm \ lib \ Doctrine \ ORM \ ORMException.php

Security.yml

security:
    encoders:
        ESS\UserBundle\Entity\User: 
            algorithm: sha512
            encode-as-base64: true
            iterations: 1

        ESS\AdminUserBundle\Entity\AdminUser:
            algorithm: sha512
            encode-as-base64: true
            iterations: 1

    role_hierarchy:
        ROLE_ADMIN:       ROLE_USER
        ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]

    providers:
        admin_area:
            entity: {class: ESSAdminUserBundle:AdminUser }

        company_area:
            entity: {class: ESSUserBundle:User, property: username}

firewalls:
        admin_area:
            pattern:    ^/admin
            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: ~
            form_login:
                login_path:  /login
                check_path: login_check
                default_target_path: /main/dashboard
                failure_path: /

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

Config.yml

orm:
    default_entity_manager: default
    #auto_generate_proxy_classes: "%kernel.debug%"
    entity_managers:
        default:
            connection: default
            mappings:

                ESSCompanyBundle: ~
                ESSAdminUserBundle: ~

        client:
            connection: client
            mappings:
                ESSUserBundle: ~

0 个答案:

没有答案