joelbutcher / socialstream

OAuth for Laravel, simplified.
https://docs.socialstream.dev
MIT License
433 stars 66 forks source link

[6.x] Fix authenticating existing users if the underlying users email has been changed #351

Closed joelbutcher closed 8 months ago

joelbutcher commented 8 months ago

Resolves #350

This PR makes a few changes to the authentication flow & responses:

  1. Updates the canRegister method to check $user and $account values. If either of these are NOT null it returns false, instructing us to attempt to authenticate the existing user.
  2. If we cannot find a user for the email on the provider, we now resolve the user from the connected account model, if one exists for the provider.
  3. Added a new test to ensure users who change their emails can still be logged in with previous providers
  4. Deprecated some response contracts and classes in favour of a more generic OAuthFailed event and OAuthFailedResponse.
  5. Replaces all usages of session() with Session facade
joelbutcher commented 8 months ago

\cc. @mystyq – this should fix the problems you're having

mystyq commented 8 months ago

@joelbutcher Yes, this fixes resolving the correct account. Thank you.