processing / processing/p5.js-web-editor

Double response and logic error in account settings update

Open
#3,905 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug On Hold
Dominant language
JavaScript
Stars
1.7k
Forks
1.7k
Avg merge
3d 4h
Merged PRs (30d)
8

Description

p5.js version

No response

What is your operating system?

None

Web browser and version

No response

Actual Behavior

In updateSettings() multiple code paths send a response but do not return, so:

  1. Social login user setting password: saveUser(res, user) is called (sends 200), then execution continues and can send 401.
  2. Password update: await saveUser(res, user) sends response, then execution falls through and saveUser() is called again in the else block.

Result: "Cannot set headers after they are sent", inconsistent client state, or users seeing errors despite success.

Location: server/controllers/user.controller/authManagement.ts lines 159–201

Expected Behavior

Each code path that sends a response should return immediately. Only one response per request.

Steps to reproduce
  1. Log in with a social account (e.g. Google) that has no password set.
  2. Go to Account settings and set a new password (no current password).
  3. Submit the form. Observe: success response may be sent, then 401 or double-response error.
  4. Alternatively: log in with email/password, change password, submit. Observe possible double response or header errors.
Snippet:
// authManagement.ts - updateSettings (simplified)
if (user.password === undefined) {
  user.password = req.body.newPassword;
  saveUser(res, user);  // sends response, no return
}
if (!req.body.currentPassword) {
  res.status(401).json({ ... });  // second response
  return;
}
// ...
await saveUser(res, user);  // line 177 - sends response
// no return - falls through to:
} else {
  await saveUser(res, user);  // line 201 - sends again
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open server/controllers/user.controller/authManagement.ts and inspect updateSettings(), especially lines 159–201 and the saveUser() calls. Reproduce the social-login password-setting and password-update flows described in the issue. Done means each request sends exactly one response without a headers-already-sent error or an incorrect 401 after success.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
authentication, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.