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

Commit 49263d5

Browse files
committed
Fixing bug triggered by Facebook not returning an email address
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).
1 parent ca385d6 commit 49263d5

File tree

5 files changed

+511
-935
lines changed

5 files changed

+511
-935
lines changed

index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ if (process.env.LOGS_SECRET) {
1414
require('now-logs')(process.env.LOGS_SECRET)
1515
}
1616

17+
process.on('uncaughtException', function(err) {
18+
console.log('Uncaught Exception: ' + err)
19+
})
20+
21+
process.on('unhandledRejection', (reason, p) => {
22+
console.log('Unhandled Rejection: Promise:', p, 'Reason:', reason)
23+
})
24+
1725
// Default when run with `npm start` is 'production' and default port is '80'
1826
// `npm run dev` defaults mode to 'development' & port to '3000'
1927
process.env.NODE_ENV = process.env.NODE_ENV || 'production'

0 commit comments

Comments
 (0)