Twitter & Github auth always creates a new user profile, fail to load an existing one
anthonygore opened this issue · 4 comments
The User.load
method in config/passport/twitter.js
and config/passport/github.js
always fails to load an existing user and will instead always create a new profile for a returning user.
The reason is that the twitter id and github id are stored as an int, not a string, but the mongoose query will have it as a string.
For twitter, there's an easy fix: the twitter profile object has another property 'id_str' so that should be used instead i.e. criteria: { 'twitter.id': profile.id }
needs to be changed to criteria: { 'twitter.id_str': profile.id }
Github does not have this option, so perhaps it should be criteria: { 'github.id': parseInt(profile.id) }
@anthonygore thanks for noticing this. Would you be able to make a PR?
Yes I will, just a moment..
PR #223
Thanks @anthonygore ! I have merged it!