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) }
The
User.load
method inconfig/passport/twitter.js
andconfig/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 tocriteria: { 'twitter.id_str': profile.id }
Github does not have this option, so perhaps it should be
criteria: { 'github.id': parseInt(profile.id) }