[5.x]: “Save and send activation email” doesn’t send the email for users with only “Moderate users”

Đang mở Phù hợp với người mới
#20,566 1 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 1 ngày

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

Đánh giá

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

Hướng nghiên cứu

Issue chỉ đến src/controllers/UsersController.php ở khoảng dòng 1343. Đọc phần kiểm tra quyền gửi email kích hoạt và so sánh với hành động “Gửi email kích hoạt”, vốn đã cho phép người dùng có quyền “Kiểm duyệt người dùng”. Cập nhật phần kiểm tra để khớp với quyền dự kiến, sau đó xác minh rằng người dùng có các quyền được liệt kê có thể lưu và gửi email kích hoạt.

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

Mô tả

bug repo:cms
What happened?
Description

craftcms/cms#17362 (fixing craftcms/cms#17360) allowed users with the “Moderate users” permission to send activation emails. The button on a user’s Permissions screen is now shown with moderateUsers, but the code that sends the email still checks for administrateUsers:

https://github.com/craftcms/cms/blob/5.x/src/controllers/UsersController.php#L1343

if (
    !$user->getIsCredentialed() &&
    $currentUser->can('administrateUsers') &&
    $this->request->getBodyParam('sendActivationEmail')
) {

So these users see the button, and clicking it saves the permissions and shows “Permissions saved.” No activation email is sent and no error is shown.

Steps to reproduce
  1. Sign in as a non-admin user with “Edit users”, “Moderate users” and “Assign user permissions”, but without “Administrate users”.
  2. Open the Permissions screen of a user who hasn’t set a password yet.
  3. Click “Save and send activation email”.
Expected behavior

The activation email is sent, the same as with the “Send activation email” action, which already only requires moderateUsers.

Actual behavior

Permissions are saved, but no activation email is sent.

Suggested fix

Change administrateUsers to moderateUsers on https://github.com/craftcms/cms/blob/dc4734d0a4ec3eef7cbf9379909048c46c74ea16/src/controllers/UsersController.php#L1343

Craft CMS version

5.11.4

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions
Ngôn ngữ chính
PHP
Star
3.6k
Fork
714
Merge trung bình
13 giờ 20 phút
Pull request đã merge (30 ngày)
471

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 craftcms/cms

Tất cả issue của craftcms/cms

Issue tương tự

Thêm issue về PHP

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.