Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple identity property for login authentication #258

Closed
atans opened this issue May 23, 2013 · 4 comments
Closed

Multiple identity property for login authentication #258

atans opened this issue May 23, 2013 · 4 comments

Comments

@atans
Copy link
Contributor

atans commented May 23, 2013

    public function loginAction()
    {
        $login = $request->getPost('login');
        if (strpos($login, '@' !== false)) {
             // use email identity property
        } else {
            // use username identity property
        }
    }

Any way to do it?
Thanks !

@superdweebie
Copy link
Contributor

I'm thinking $this->serviceLocator->get('Zend\Authentication\AuthenticationService')->getAdapter()->setIdentityProperty('email' | 'username')

@Ocramius
Copy link
Member

As @superdweebie said, this is currently unsupported

@atans
Copy link
Contributor Author

atans commented May 23, 2013

I found ObjectRepository::getOptions() from master branch

https://github.com/doctrine/DoctrineModule/blob/master/src/DoctrineModule/Authentication/Adapter/ObjectRepository.php#L77

    public function loginAction()
    {
        $login = $request->getPost('login');

        $authenticationService = $this->serviceLocator->get('Zend\Authentication\AuthenticationService');
        $adapter               = $authenticationService->getAdapter();
        if (strpos($login, '@' !== false)) {
             // use email identity property
             $adapter->getOptions()->setIdentityProperty('email');
        } else {
            // use username identity property
             $adapter->getOptions()->setIdentityProperty('useranme');
        }
       // Do something...
    }

@Ocramius, Is this right ?

@Ocramius
Copy link
Member

@atans that may be a valid workaround, yes.

Closing, since I think the feature doesn't need an implementation in the module itself.

gencer pushed a commit to gencer/DoctrineModule that referenced this issue Apr 11, 2014
Some commands were not returning the correct exit codes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants