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

Handle null email in oauth login #9612

Merged
merged 3 commits into from
Jul 26, 2018
Merged

Handle null email in oauth login #9612

merged 3 commits into from
Jul 26, 2018

Conversation

dnna
Copy link
Contributor

@dnna dnna commented Jul 23, 2018

Q A
Branch? 1.1
Bug fix? yes
New feature? no
BC breaks? no
License MIT

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.

Copy link
Member

@lchrusciel lchrusciel left a 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?

@dnna
Copy link
Contributor Author

dnna commented Jul 24, 2018

@lchrusciel spec has been added

}
} else {
Copy link
Member

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]);
Copy link
Member

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]);

@dnna
Copy link
Contributor Author

dnna commented Jul 25, 2018

@Zales0123 changes done :)

@pamil pamil added the Potential Bug Potential bugs or bugfixes, that needs to be reproduced. label Jul 26, 2018
@pamil pamil merged commit 6c0b740 into Sylius:1.1 Jul 26, 2018
@pamil
Copy link
Contributor

pamil commented Jul 26, 2018

Thanks! 🥇

@dnna dnna deleted the patch-1 branch July 26, 2018 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Potential Bug Potential bugs or bugfixes, that needs to be reproduced.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants