-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Labels
BugError or unexpected behaviorsError or unexpected behaviors
Description
p5.js version
No response
What is your operating system?
None
Web browser and version
No response
Actual Behavior
Google strategy accesses profile._json.emails[0] without checking that emails exists and has length. If Google does not return emails, this throws TypeError: Cannot read property '0' of undefined and crashes the OAuth flow.
Location: server/config/passport.js Google Strategy, lines 244, 261, 265
Expected Behavior
Before using profile._json.emails[0], code should verify profile._json?.emails exists and has at least one element. If not, call done(null, false, { msg: '...' }) instead of throwing.
Steps to reproduce
- Use (or mock) a Google OAuth profile that has no
emailsor emptyemailsarray. - Complete Google sign-in so the strategy callback runs.
- Observe unhandled TypeError and OAuth failure instead of a user-friendly message.
Snippet:
// passport.js - Google strategy
const existingUser = await User.findOne({
google: profile._json.emails[0].value // crashes if emails undefined
}).exec();
// ...
const primaryEmail = profile._json.emails[0].value;
// ...
req.user.google = profile._json.emails[0].value;Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugError or unexpected behaviorsError or unexpected behaviors