Skip to content
This repository has been archived by the owner on Jul 15, 2020. It is now read-only.

Commit

Permalink
Fixing bug triggered by Facebook not returning an email address
Browse files Browse the repository at this point in the history
Fixes #22.

* Have refactored how oAuth services that don't return email addresses work, which is cleaner in the code and and makes it easier to add providers that don't return them.
* The sign-in page now shows "N/A" if we don't have a valid email address for the user (i.e. if the value is a placeholder email address ending in @localhost.localdomain).
* Have added in the defensive checks to fix the bug which triggered the crash.
* Also added hooks to log uncaughtException and unhandledRejection errors to make it easy to debug issues like this in production with now-logs.

I don't know why the Facebook API is no longer returning an email address, even though we already explicitly ask for that field. I don't know if this something specific to privacy settings on my account, or a result in the change on the API. Either way, Facebook oAuth works again, we just aren't able to grab the email address the user has given to Facebook (and we now just handle that gracefully).

It's worth noting the reason we bother with a temporary email address at all is because it makes it easier to also support email based sign-in at the same time as supporting oAuth (if we only did oAuth then we wouldn't have to care about an email address field).
  • Loading branch information
iaincollins committed May 14, 2017
1 parent ca385d6 commit 49263d5
Show file tree
Hide file tree
Showing 5 changed files with 511 additions and 935 deletions.
8 changes: 8 additions & 0 deletions index.js
Expand Up @@ -14,6 +14,14 @@ if (process.env.LOGS_SECRET) {
require('now-logs')(process.env.LOGS_SECRET)
}

process.on('uncaughtException', function(err) {
console.log('Uncaught Exception: ' + err)
})

process.on('unhandledRejection', (reason, p) => {
console.log('Unhandled Rejection: Promise:', p, 'Reason:', reason)
})

// Default when run with `npm start` is 'production' and default port is '80'
// `npm run dev` defaults mode to 'development' & port to '3000'
process.env.NODE_ENV = process.env.NODE_ENV || 'production'
Expand Down

0 comments on commit 49263d5

Please sign in to comment.