来自2个实体的Zend Framework 2 / Doctrine身份验证

时间:2015-08-06 19:49:41

标签: php zend-framework doctrine-orm zend-framework2

我有两个实体:UserMember来访问我的ZF2应用程序中的不同模块。

我有两种不同的登录表单来建立连接。

Member专用模块的配置:

'doctrine'        =>
            [
                'authenticationservice' =>
                    [
                        'platform' => true,
                    ],
                'authenticationstorage' =>
                    [
                        'platform' => true,
                    ],
                'authenticationadapter' =>
                    [
                        'platform' => true
                    ],
                'authentication'        =>
                    [
                        'platform' =>
                            [
                                'storage'            => 'Platform_Auth',
                                'objectManager'      => EntityManager::class,
                                'identityClass'      => Member::class,
                                'identityProperty'   => 'login',
                                'credentialProperty' => 'password',
                                'credentialCallable' => function (Member $member, $password)
                                    {
                                        return ($member->getPassword() === md5($password));
                                    }
                            ],
                    ]
            ],

User专用模块

'doctrine'     =>
            [
                'authenticationservice' =>
                    [
                        'admin' => true,
                    ],
                'authenticationstorage' =>
                    [
                        'admin' => true,
                    ],
                'authenticationadapter' =>
                    [
                        'admin' => true
                    ],
                'authentication'        =>
                    [
                        'admin' =>
                            [
                                'storage'            => 'Admin_Auth',
                                'objectManager'      => EntityManager::class,
                                'identityClass'      => User::class,
                                'identityProperty'   => 'login',
                                'credentialProperty' => 'password',
                                'credentialCallable' => function (User $user, $password)
                                    {
                                        return ($user->getPassword() === md5($password));
                                    }
                            ]
                    ]
            ],

如何使用2种不同配置的Doctrine身份验证?

有没有办法实现这个目标?

修改 我可以使用一个共享身份验证工厂和基于路由的扩展(平台/管理员)...但我不知道这是不是一个好主意......

edit2

配置存储时出现另一个错误:

“.... Zend \ ServiceManager \ ServiceManager :: get无法在...中为Admin_Auth获取或创建实例”

非常感谢任何帮助

0 个答案:

没有答案