-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Handle null email in oauth login #9612
Conversation
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.
But can we at least test it with spec?
@lchrusciel spec has been added |
} | ||
} else { |
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.
I think we don't need that else
$userManager->persist($user)->shouldNotBeCalled(); | ||
$userManager->flush()->shouldNotBeCalled(); | ||
|
||
$this->shouldThrow(UsernameNotFoundException::class)->during('loadUserByOAuthUserResponse', [$response]); |
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.
There is a lot of unnecessary code there :) The only required is:
$response->getResourceOwner()->willReturn($resourceOwner);
$resourceOwner->getName()->willReturn('google');
$response->getUsername()->willReturn('username');
$oauthRepository->findOneBy(['provider' => 'google', 'identifier' => 'username'])->willReturn(null);
$response->getEmail()->willReturn(null);
$userRepository->findOneByEmail(Argument::any())->shouldNotBeCalled();
$this->shouldThrow(UsernameNotFoundException::class)->during('loadUserByOAuthUserResponse', [$response]);
@Zales0123 changes done :) |
Thanks! 🥇 |
If the user tries to log in with Facebook but chooses to not give their email, Sylius crashes because it attempts to insert a user with null email into the database. This PR fixes this by checking this case in the user provider.