Open ClemensSahs opened 10 years ago
Do we need to provide the resulting user entity at all here? From the listener you could pull an instance of the AuthenticationService and extract the user details from there.
My only point is that looks like a wrong behavior? I my mind AdapterChainEvent::getIdentity and \Zend\Authentication\AuthenticationService::getIdentity must follow the same behavior.
The have the same name so the must do the same...
And on the other Hand, why we need to hold the User-ID in the event, without other data? The only UseCase I see for a listener is to work with the User Date.
So you call pull AuthenticationService and call a result for a ID? Result of this 2 Database request... first for the login and second on the listener. If you have more that one listener... this example is a n+1
Currently I don't have this problem by my self.
AuthenticationService::getIdentity
doesn't hit the database, it just returns the user entity that it was given during the bootstrap process and returns the same instance each time you call the method.
@adamlundrigan Yes sorry the n+1 request is not exists... but this was only a side point on this discussion...
API - inconsistency and the 2 request are already there...
In #327 we have this topic...
ZfcUser/Authentication/Adapter/Db.php#L108-L116
If there is a reason to holt the user_id as identity then we can add a userEntity additional? Or is there something else I don't see.
I write two patches $event->setIdentity($userObject) and $event->setEntity($userObject)
ping @EvanDotPro @Danielss89