This will give TypeError: Cannot read property '0' of undefined is the user doesn't have a public email address.
If you add scope: [ 'user:email' ] into your GithubStrategy constructor's options it works.
The other issue is that by default you get the first of the user's email addresses, which may not be their primary one. If you're only get one email, should probably be the primary. Here's how I rejigged the code a bit:
config/passport/github.js
has this on line 31:email: profile.emails[0].value
This will give
TypeError: Cannot read property '0' of undefined
is the user doesn't have a public email address.If you add
scope: [ 'user:email' ]
into your GithubStrategy constructor's options it works.The other issue is that by default you get the first of the user's email addresses, which may not be their primary one. If you're only get one email, should probably be the primary. Here's how I rejigged the code a bit: