Double response and logic error in account settings update

Đang mở
#3,905 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 4 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
55/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
typescript
Lĩnh vực
authentication, backend

Hướng nghiên cứu

Mở server/controllers/user.controller/authManagement.ts và kiểm tra updateSettings(), đặc biệt là các dòng 159–201 và các lệnh gọi saveUser(). Tái hiện các luồng thiết lập mật khẩu và cập nhật mật khẩu bằng social-login được mô tả trong issue. Hoàn tất khi mỗi request gửi chính xác một response mà không có lỗi headers-already-sent hoặc 401 không chính xác sau khi thành công.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Bug On Hold
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
}
Ngôn ngữ chính
JavaScript
Star
1.7k
Fork
1.7k
Merge trung bình
8 ngày 22 giờ
Pull request đã merge (30 ngày)
14

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của processing/p5.js-web-editor

Tất cả issue của processing/p5.js-web-editor

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.