sorcery
sorcery copied to clipboard
🐛 Fix return value of #add_provider_to_user on User instance
Hi, thank you for the great library! Using it with ease. Just noticed a small bug on the return value of #add_provider_to_user
here:
https://github.com/Sorcery/sorcery/blob/master/lib/sorcery/model/submodules/external.rb#L99-L100
-
Before, the method would return an instance of Authentication, instead of the original intention to return an instance of the current user.
-
Arguably returning the the instance of the current user is not very useful, as it's already known 🤷♂, but at least it matches the current example here:
https://github.com/Sorcery/sorcery/blob/c30cefa751c364ee20b361eb63a766f782b69e5e/spec/rails_app/app/controllers/sorcery_controller.rb#L447-L452
Thanks @mladenilic for looking over. I guess indeed you're right that there's only one place referring to the return value of the method being user instead of authentication:
https://github.com/Sorcery/sorcery/blob/c30cefa751c364ee20b361eb63a766f782b69e5e/spec/rails_app/app/controllers/sorcery_controller.rb#L448-L452
Happy to change the code back to return an authentication, adjust the tests, and change that example code line, etc.. if you think that's more sensible.
It seems that the original intention was to return the user instance. However, I agree with you that returning authentication instance makes more sense.
I think we should revert back to returning authentication instance, but keep everything else (guard clause simplification and user
-> authentication
variable rename). Also, you can fix that spec (variable name is confusing).
Thanks!
Thanks for your feedback @mladenilic . All amended as talked about. Let me know if you'd like me to change anything else. Will be happy to. Thanks!