-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
Awaiting Maintainer ApprovalNeeds review from a maintainer before moving forwardNeeds review from a maintainer before moving forwardBugError or unexpected behaviorsError or unexpected behaviors
Description
p5.js version
latest
What is your operating system?
None
Web browser and version
all
Actual Behavior
In server/config/passport.js at line 180, the GitHub OAuth callback uses an assignment operator (=) instead of a strict comparison (===) inside a .find() callback:
if (existingEmailUsers.length > 1) {
existingEmailUser = existingEmailUsers.find(
(u) => (u.email = primaryEmail) // assignment, not comparison
);
}Because u.email = primaryEmail is an assignment:
- It overwrites
u.emailwithprimaryEmailfor every user iterated - The expression returns the assigned string, which is always truthy
.find()returns the first user in the array instead of the one that actually matchesprimaryEmail
This means when a user has multiple p5.js Editor accounts with emails tied to the same GitHub account, the wrong account may get linked and other users' email fields get silently corrupted during iteration.
Expected Behavior
The callback should use strict comparison (===) so that .find() returns the user whose email actually matches primaryEmail:
existingEmailUser = existingEmailUsers.find(
(u) => (u.email === primaryEmail) // comparison
);Steps to reproduce
- Create two p5.js Editor accounts with different emails (e.g.,
user-a@example.comanduser-b@example.com) - Add both emails to the same GitHub account
- Log in via GitHub OAuth
- The
existingEmailUsersarray will contain both accounts - Due to the
=operator,.find()always returns the first user regardless of which email isprimaryEmail - The wrong account gets linked to the GitHub profile
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Awaiting Maintainer ApprovalNeeds review from a maintainer before moving forwardNeeds review from a maintainer before moving forwardBugError or unexpected behaviorsError or unexpected behaviors