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

オープン 初心者向け
#20,566 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
1/5
見積もり時間
1〜3時間
初心者へのやさしさ
84/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
php

調査の方向性

issue は src/controllers/UsersController.php の 1343 行目付近を示しています。アクティベーションメールの権限チェックを読み、「アクティベーションメールを送信」アクションと比較してください。このアクションでは、「ユーザーをモデレート」の権限を持つユーザーがすでに許可されています。期待される権限に一致するようチェックを更新し、記載された権限を持つユーザーがアクティベーションメールを保存して送信できることを確認してください。

索引モデルが issue の本文から書いたものです。

説明

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
主要言語
PHP
スター
3.6k
フォーク
714
平均マージ
13時間 20分
マージ済み PR(30日)
471

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

craftcms/cms のほかの issue

craftcms/cms の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。