1

I am working on a site in which user can enter two email address(primary and secondary) along with password.

If user enters his primary email and password, he gets logged in successfully.

But, what I am trying to provide is if user enters his secondary email instead of primary, even then he gets logged in. And the problem I am getting is how to create an alternate Doctrine Auth Adapter or something like that.

this is what I have done in my module.config.php:

'doctrine' => array(
    'driver' => array(
        __NAMESPACE__ . '_driver' => array(
            'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
            'cache' => 'array',
            'paths' => array(__DIR__ . '/../src/' . __NAMESPACE__ . '/Entity')
        ),
        'orm_default' => array(
            'drivers' => array(
                __NAMESPACE__ . '\Entity' => __NAMESPACE__ . '_driver'
            )
        )
    ),
    'authentication' => array(
        'orm_default' => array(
            'object_manager' => 'Doctrine\ORM\EntityManager',
            'identity_class' => 'User\Entity\LoginDetails',
            'identity_property' => 'primary_email',
            'credential_property' => 'password',
        ),
    ),
)

Is there any option to add an identity property which will be alternative ?

I am using Zend framework 2 and Doctrine 2
Deepanshu Goyal
  • 2,738
  • 3
  • 34
  • 61

1 Answers1

3

Is there any option to add an identity property which will be alternative ?

No, there is no such option built-in to DoctrineModule.

Consider extending DoctrineModule\Authentication\Adapter\ObjectRepository to override the authenticate() method.

Then, at minimum, you'll want to replace the default adapter with your new more different one. If you look at the various factories in DoctrineModule, you should be off to a good start.

Basically, one of your modules will want to override the doctrine.authenticationadapter.[orm|odm]_default configuration key in the ServiceManager. That will cause DoctrineModule to inject your extended ObjectRepository into the AuthenticationService in place of you the default one.

timdev
  • 61,857
  • 6
  • 82
  • 92
  • thanks, but where should I override it. Do yo mean I should create a new class but when will it get called. Sorry I have never overridden any library classes before – Deepanshu Goyal May 13 '14 at 07:51
  • 1
    You would override it in your module's config -- either in module.config.php, or in your module's getServiceConfig() method. – timdev May 13 '14 at 19:35