Zhaofeng Li has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/193658

Change subject: Add 'login' user right
......................................................................

Add 'login' user right

This commit adds the 'login' user right and
assigns it to registered users by default. It is
required for an account to be able to log in.

This user right may be useful for approve-based
wikis where new accounts need to be manually
verified before they can log in.

Bug: T48057
Change-Id: I68c6f52e7738591bbc2d7c8e40f16abf9ff39290
---
M includes/DefaultSettings.php
M includes/User.php
M includes/specials/SpecialUserlogin.php
M languages/i18n/en.json
M languages/i18n/qqq.json
5 files changed, 17 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/58/193658/1

diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php
index 6786f81..695cb20 100644
--- a/includes/DefaultSettings.php
+++ b/includes/DefaultSettings.php
@@ -4551,6 +4551,7 @@
 #$wgGroupPermissions['*']['patrolmarks'] = false; // let anons see what was 
patrolled
 
 // Implicit group for all logged-in accounts
+$wgGroupPermissions['user']['login'] = true;
 $wgGroupPermissions['user']['move'] = true;
 $wgGroupPermissions['user']['move-subpages'] = true;
 $wgGroupPermissions['user']['move-rootuserpages'] = true; // can move root 
userpages
diff --git a/includes/User.php b/includes/User.php
index 7025717..0766801 100644
--- a/includes/User.php
+++ b/includes/User.php
@@ -134,6 +134,7 @@
                'import',
                'importupload',
                'ipblock-exempt',
+               'login',
                'managechangetags',
                'markbotedits',
                'mergehistory',
diff --git a/includes/specials/SpecialUserlogin.php 
b/includes/specials/SpecialUserlogin.php
index f2f6b69..27b47c9 100644
--- a/includes/specials/SpecialUserlogin.php
+++ b/includes/specials/SpecialUserlogin.php
@@ -42,6 +42,7 @@
        const NEED_TOKEN = 12;
        const WRONG_TOKEN = 13;
        const USER_MIGRATED = 14;
+       const NO_LOGIN_RIGHT = 15;
 
        /**
         * Valid error and warning messages
@@ -714,6 +715,12 @@
 
                $u = User::newFromName( $this->mUsername );
 
+               // Check if the user has the 'login' right,
+               // and abort if the user doesn't.
+               if ( !in_array( "login", $u->getRights() ) ) {
+                       return self::NO_LOGIN_RIGHT;
+               }
+
                // Give extensions a way to indicate the username has been 
updated,
                // rather than telling the user the account doesn't exist.
                if ( !Hooks::run( 'LoginUserMigrated', array( $u, &$msg ) ) ) {
@@ -1029,6 +1036,10 @@
                                }
                                $this->mainLoginForm( $this->msg( $error, 
$params )->text() );
                                break;
+                       case self::NO_LOGIN_RIGHT:
+                               $error = $this->mAbortLoginErrorMsg ?: 
'login-nologinright';
+                               $this->mainLoginForm( $this->msg( $error, 
$this->mUsername )->escaped() );
+                               break;
                        default:
                                throw new MWException( 'Unhandled case value' );
                }
diff --git a/languages/i18n/en.json b/languages/i18n/en.json
index 31c766f..93fef04 100644
--- a/languages/i18n/en.json
+++ b/languages/i18n/en.json
@@ -487,6 +487,7 @@
        "createaccount-text": "Someone created an account for your email 
address on {{SITENAME}} ($4) named \"$2\", with password \"$3\".\nYou should 
log in and change your password now.\n\nYou may ignore this message, if this 
account was created in error.",
        "login-throttled": "You have made too many recent login 
attempts.\nPlease wait $1 before trying again.",
        "login-abort-generic": "Your login was unsuccessful - Aborted",
+       "login-nologinright": "You don't have permission to log in.",
        "login-migrated-generic": "Your account has been migrated, and your 
username no longer exist on this wiki.",
        "loginlanguagelabel": "Language: $1",
        "loginlanguagelinks": "* {{#language:de}}|de\n* {{#language:en}}|en\n* 
{{#language:eo}}|eo\n* {{#language:fr}}|fr\n* {{#language:es}}|es\n* 
{{#language:it}}|it\n* {{#language:nl}}|nl",
@@ -1081,6 +1082,7 @@
        "right-createpage": "Create pages (which are not discussion pages)",
        "right-createtalk": "Create discussion pages",
        "right-createaccount": "Create new user accounts",
+       "right-login": "Log in with the account",
        "right-minoredit": "Mark edits as minor",
        "right-move": "Move pages",
        "right-move-subpages": "Move pages with their subpages",
@@ -1158,6 +1160,7 @@
        "action-createtalk": "create discussion pages",
        "action-createaccount": "create this user account",
        "action-history": "view the history of this page",
+       "action-login": "log in",
        "action-minoredit": "mark this edit as minor",
        "action-move": "move this page",
        "action-move-subpages": "move this page, and its subpages",
diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json
index 6253fc9..acf3903 100644
--- a/languages/i18n/qqq.json
+++ b/languages/i18n/qqq.json
@@ -652,6 +652,7 @@
        "login-throttled": "Error message shown at [[Special:UserLogin]] after 
the user has tried to login with incorrect password too many times.\n\nThe user 
has to wait a certain time before trying to log in again.\n\nParameters:\n* $1 
- the time to wait before the next login attempt. Automatically formatted using 
the following duration messages:\n** {{msg-mw|Duration-millennia}}\n** 
{{msg-mw|Duration-centuries}}\n** {{msg-mw|Duration-decades}}\n** 
{{msg-mw|Duration-years}}\n** {{msg-mw|Duration-weeks}}\n** 
{{msg-mw|Duration-days}}\n** {{msg-mw|Duration-hours}}\n** 
{{msg-mw|Duration-minutes}}\n** {{msg-mw|Duration-seconds}}\n\nThis is a 
protection against robots trying to find the password by trying lots of 
them.\nThe number of attempts and waiting time are configured via 
[[mw:Manual:$wgPasswordAttemptThrottle|$wgPasswordAttemptThrottle]].\nThis 
message is used in html.\n{{identical|Login throttled}}",
        "login-abort-generic": "The generic unsuccessful login message is used 
unless otherwise specified by hook writers",
        "login-migrated-generic": "The generic unsuccessful login message when 
the user's account has been updated, and their username no longer exist",
+       "login-nologinright": "Error message shown at [[Special:UserLogin]] 
when the user isn't permitted to log in.",
        "loginlanguagelabel": "Used on [[Special:UserLogin]] if 
$wgLoginLanguageSelector is true. Parameters:\n* $1 - a pipe-separated list 
built from the names that appear in the message 
{{msg-mw|Loginlanguagelinks}}.\n{{Identical|Language}}",
        "loginlanguagelinks": "{{notranslate}}",
        "suspicious-userlogout": "Used when the logout request looks 
suspicious, in Special:UserLogout.",

-- 
To view, visit https://gerrit.wikimedia.org/r/193658
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I68c6f52e7738591bbc2d7c8e40f16abf9ff39290
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Zhaofeng Li <he...@zhaofeng.li>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to