Trying to workaround a crash I saw in the logs for GitHub auth.

This commit is contained in:
Nick Winter 2014-11-24 14:23:54 -08:00
parent d7f8a212a4
commit 16e264788a

View file

@ -27,7 +27,10 @@ module.exports.setup = (app) ->
request.get {uri: 'https://api.github.com/user', headers: headers}, (err, r, response) ->
return log.error err if err?
githubUser = JSON.parse response
emailLower = githubUser.email.toLowerCase()
log.info 'Got GitHub auth callback response', githubUser
emailLower = githubUser.email?.toLowerCase()
if not emailLower
return errors.serverError res, "Problem finding GitHub user with that identity."
# GitHub users can change emails
User.findOne {$or: [{emailLower: emailLower}, {githubID: githubUser.id}]}, (err, user) ->