fix issue where social user saving fails after oauth callback #134
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Greetings dojo community, thank you for this awesome project
Issue
SocialProviderUser
Reproduce
1- use the Laravel installer and install a fresh latest version application (I used inertia vue stack)
2- install and configure the auth package
3- configure your social auth service (I tried both google and github)
4- try to register with provider, it will fail on the callback when creating a user
Cause
the model
SocialProviderUser
has a custom (composite?) primaryKey attribute that is an array, see :051748d#diff-79bf4b0babdccd06a4491c7c0c134e34a898e01eac9be350b7430c4184ad44c1R14this will cause this function in the laravel framework to throw a type error : laravel/framework@92beae3#diff-59d24f1a8f0dd1e51ee7dffc8778133711634e928ecef4a91b63fc3851cb1579R435
array_key_exists() take a $key that must be a primitive, in this case an array is passed ['user_id', 'provider_slug'] which causes a type error:
The fix
$primaryKey = ['user_id', 'provider_slug'];
to protected$primaryKey = 'user_id';
and it will work