Closed kukoman closed 2 years ago
What is the storage in the $authService
?
DoctrineModule\Authentication\Storage\ObjectRepository // also full entity $authService->getStorage()->read()
So the auth adapter is not actually returning the entity? Can you check our existing tests? I can't see the fault in your code (if there is any)
well, I feel little bit funny... I overlooked the read method :/ perhaps you can mention it in the documentation
if (($identity = $this->options->getStorage()->read())) {
return $this->options->getObjectRepository()->find($identity);
}
thank you for your time
@kukoman that shouldn't be the default way of doing this. re-opening as this is indeed a bug.
so just to sum it up; maybe the documentation need improving or I was doing something wrong but here is more detailed explanation:
$authService = $this->getServiceLocator()->get('Zend\Authentication\AuthenticationService');
$adapter = $authService->getAdapter();
$adapter->setIdentityValue($data['login']);
$adapter->setCredentialValue($data['password']);
$authResult = $authService->authenticate();
if ($authResult->isValid()) {
... some more magic with storage write
$identity = $authResult->getIdentity();
$identity->setPassword(null);
$authService->getStorage()->write($identity);
}
this will store only the entity identity key/value but from documentation I understood that also writing to the storage performs the same logic - however when I've done it I ended up with full entity in the session
if someone can reproduce it than it is indeed a bug :)
Well, I'd expect $authResult->getIdentity()
to contain an object
I've seen the SessionStorage
put the serialized getIdentity()
object into the session too.
What is the correct solution? Unserialize the identity and call merge()
and return the merged identity?
no matter what I do it seems like there is a whole entity saved as identity
doctrine config:
factory in my module
my apigility rpc class:
I can see that ObjectRepository::write works correctly but somehow it will get rewritten when I call getIdentity()
anyone can help me to find this?