From d7049bc9738e49bd71640e83e6e8de7b2a504dca Mon Sep 17 00:00:00 2001 From: Max Semenik Date: Wed, 4 Sep 2019 18:12:09 -0700 Subject: [PATCH] Add a preference to require email for password resets The actual functonality will come in a later commit. Bug: T231495 Change-Id: I9977b0d51a2b89b79c199bc4423f123e581e2a2f --- includes/DefaultSettings.php | 10 ++++++++++ includes/preferences/DefaultPreferencesFactory.php | 11 +++++++++++ languages/i18n/en.json | 2 ++ languages/i18n/qqq.json | 2 ++ 4 files changed, 25 insertions(+) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 81de1a07c2..6efb9e80d2 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -4897,6 +4897,7 @@ $wgDefaultUserOptions = [ 'wllimit' => 250, 'useeditwarning' => 1, 'prefershttps' => 1, + 'requireemail' => 0, ]; /** @@ -4966,6 +4967,15 @@ $wgSessionProviders = [ ], ]; +/** + * Temporary feature flag that controls whether users will see a checkbox allowing them to + * require providing email during password resets. + * + * @deprecated This feature is under development, don't assume this flag's existence or function + * outside of MediaWiki. + */ +$wgAllowRequiringEmailForResets = false; + /** @} */ # end user accounts } /************************************************************************//** diff --git a/includes/preferences/DefaultPreferencesFactory.php b/includes/preferences/DefaultPreferencesFactory.php index 8a82add61f..66c2bc33e5 100644 --- a/includes/preferences/DefaultPreferencesFactory.php +++ b/includes/preferences/DefaultPreferencesFactory.php @@ -84,6 +84,7 @@ class DefaultPreferencesFactory implements PreferencesFactory { * @since 1.34 */ public static $constructorOptions = [ + 'AllowRequiringEmailForResets', 'AllowUserCss', 'AllowUserCssPrefs', 'AllowUserJs', @@ -620,6 +621,16 @@ class DefaultPreferencesFactory implements PreferencesFactory { } } + if ( $this->options->get( 'AllowRequiringEmailForResets' ) ) { + $defaultPreferences['requireemail'] = [ + 'type' => 'toggle', + 'label-message' => 'tog-requireemail', + 'help-message' => 'prefs-help-requireemail', + 'section' => 'personal/email', + 'disabled' => $disableEmailPrefs, + ]; + } + if ( $this->options->get( 'EnableUserEmail' ) && $user->isAllowed( 'sendemail' ) ) { $defaultPreferences['disablemail'] = [ 'id' => 'wpAllowEmail', diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 816839c629..03c3c28aaa 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -47,6 +47,7 @@ "tog-useeditwarning": "Warn me when I leave an edit page with unsaved changes", "tog-prefershttps": "Always use a secure connection while logged in", "tog-showrollbackconfirmation": "Show a confirmation prompt when clicking on a rollback link", + "tog-requireemail": "Require email for password resets", "underline-always": "Always", "underline-never": "Never", "underline-default": "Skin or browser default", @@ -1151,6 +1152,7 @@ "prefs-help-email": "Email address is optional, but is needed for password resets, should you forget your password.", "prefs-help-email-others": "You can also choose to let others contact you by email through a link on your user or talk page.\nYour email address is not revealed when other users contact you.", "prefs-help-email-required": "Email address is required.", + "prefs-help-requireemail": "If checked, will only send password reset emails if the resetting person has provided both username and email for this account.", "prefs-info": "Basic information", "prefs-i18n": "Internationalisation", "prefs-signature": "Signature", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 50b0658755..600fe31c3f 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -256,6 +256,7 @@ "tog-useeditwarning": "Used as label for the checkbox in [[Special:Preferences#mw-prefsection-editing|Special:Preferences]].", "tog-prefershttps": "Toggle option used in [[Special:Preferences]] that indicates if the user wants to use a secure connection when logged in", "tog-showrollbackconfirmation": "Toggle option used in [[Special:Preferences]] to enable/disable rollback confirmation prompt. Should be visible only to users with rollback rights.", + "tog-requireemail": "Toggle option used in [[Special:Preferences]]. Should be only visible to users who have confirmed their email address.\n\nSee also: {{msg-mw|prefs-help-requireemail}}", "underline-always": "Used in [[Special:Preferences#mw-prefsection-rendering|Preferences]].\n\nThis option means \"always underline links\", there are also options {{msg-mw|Underline-never}} and {{msg-mw|Underline-default}}.\n\n{{Gender}}\n{{Identical|Always}}", "underline-never": "Used in [[Special:Preferences#mw-prefsection-rendering|Preferences]].\n\nThis option means \"never underline links\", there are also options {{msg-mw|Underline-always}} and {{msg-mw|Underline-default}}.\n\n{{Gender}}\n{{Identical|Never}}", "underline-default": "Used in [[Special:Preferences#mw-prefsection-rendering|Preferences]].\n\nThis option means \"underline links as in your user skin or your browser\", there are also options {{msg-mw|Underline-never}} and {{msg-mw|Underline-always}}.\n\n{{Gender}}\n{{Identical|Browser default}}", @@ -1360,6 +1361,7 @@ "prefs-help-email": "Shown as explanation text on [[Special:Preferences]] > {{int:prefs-personal}} > {{int:email}}.\n\nSee also:\n* {{msg-mw|prefs-help-email-required|help}}\n* {{msg-mw|prefs-help-email-others|help}}\n* {{msg-mw|prefs-changeemail|link title}}\n* {{msg-mw|prefs-setemail|link title}}", "prefs-help-email-others": "This text is shown on account creation, below the description of the e-mail address field (which is optional).\n\nSee also:\n* {{msg-mw|prefs-help-email-required|help}}\n* {{msg-mw|prefs-help-email|help}}\n* {{msg-mw|prefs-changeemail|link title}}\n* {{msg-mw|prefs-setemail|link title}}", "prefs-help-email-required": "Shown as explanation text on [[Special:Preferences]] > {{int:prefs-personal}} > {{int:email}}.\n\nSee also:\n* {{msg-mw|prefs-help-email|help}}\n* {{msg-mw|prefs-help-email-others|help}}\n* {{msg-mw|prefs-changeemail|link title}}\n* {{msg-mw|prefs-setemail|link title}}", + "prefs-help-requireemail": "Shown as explanation text on [[Special:Preferences]] > {{int:prefs-personal}} > {{int:email}}.\n\nSee also: {{msg-mw|tog-requireemail}}", "prefs-info": "Header for the box giving basic information on the user account, displayed on the 'user profile' tab of the [[Special:Preferences|user preferences]] special page.\n{{Identical|Basic information}}", "prefs-i18n": "Field set legend for user preferences regarding the interface language", "prefs-signature": "{{Identical|Signature}}", -- 2.20.1