-
Notifications
You must be signed in to change notification settings - Fork 109
Test passing identity instance to persistIdentity() and setIdentity() #449
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
Conversation
|
|
||
| $service = new AuthenticationService(); | ||
|
|
||
| $result = $service->persistIdentity($request, $response, $identity); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passing an Identity instance here would mean SessionAuthenticate would store that instance in the session. But when one uses form login the instance stored in session is an Entity (or array), not an IdentityInterface instance.
IMO it's better to avoid such discrepancy. The authenticators should always deal with the "raw" identity object and only AuthenticationService should deal with IdentityInterface instances.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That said a clean way to fix the regression would be make buildIdentity() simply return the argument if it's already an IdentityInterface instance. That would also avoid the object type checks at multiple places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The authenticators should always deal with the "raw" identity object and decorating it with IdentityInterface should be left to AuthenticationService.
The thing is that sometimes the "raw" identity object is an identity instance itself. If your User entity already implements IdentityInterface that is. And this test covers that case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If your User entity already implements IdentityInterface that is.
Ah, I had overlooked that case. Could you please add a comment stating this info in the relevant test case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ADmad done and done.
This adds missing tests for calling persistIdentity() and setIdentity() with identity instance.
Refs #448
PS. I've also removed deprecated method calls form tests.