Isarra has submitted this change and it was merged.
Change subject: Add patch for 1.21.2
......................................................................
Add patch for 1.21.2
Bug: 55640
Change-Id: I04bd4398daf31d2f07825db17819e6654a8f3466
---
A SpecialUserlogin.php-1.21.2.patch
1 file changed, 89 insertions(+), 0 deletions(-)
Approvals:
Isarra: Verified; Looks good to me, approved
diff --git a/SpecialUserlogin.php-1.21.2.patch
b/SpecialUserlogin.php-1.21.2.patch
new file mode 100644
index 0000000..dd14aa5
--- /dev/null
+++ b/SpecialUserlogin.php-1.21.2.patch
@@ -0,0 +1,89 @@
+diff --git a/includes/specials/SpecialUserlogin.php
b/includes/specials/SpecialUserlogin.php
+index eef6691..7f18d7b 100644
+--- a/includes/specials/SpecialUserlogin.php
++++ b/includes/specials/SpecialUserlogin.php
+@@ -318,6 +318,12 @@ class LoginForm extends SpecialPage {
+ return Status::newFatal( 'wrongpassword' );
+ }
+
++ // Patch for MediaWikiAuth extension
++ if ( self::checkImportableUser( $this->mUsername ) ) {
++ return Status::newFatal( 'userexists' );
++ }
++ // Patch ends here
++
+ // If we are not allowing users to login locally, we should be
checking
+ // to see if the user is actually able to authenticate to the
authenti-
+ // cation server before they create an account (otherwise, they
can
+@@ -726,8 +732,13 @@ class LoginForm extends SpecialPage {
+ wfDebug( __METHOD__ . ": user does not exist\n"
);
+ return self::NOT_EXISTS;
+ }
+- if ( !$wgAuth->authenticate( $user->getName(),
$this->mPassword ) ) {
++ // Patch for MediaWikiAuth extension
++ $errormsg = null;
++ if ( !$wgAuth->authenticate( $user->getName(),
$this->mPassword, $errormsg ) ) {
+ wfDebug( __METHOD__ . ":
\$wgAuth->authenticate() returned false, aborting\n" );
++ // The AuthPlugin may have set a custom error
message
++ $this->mainLoginForm( isset( $errormsg ) ?
$errormsg : wfMessage( 'wrongpassword' )->text() );
++ // Patch ends here
+ return self::WRONG_PLUGIN_PASS;
+ }
+ }
+@@ -805,7 +816,7 @@ class LoginForm extends SpecialPage {
+ $this->mainLoginForm( $this->msg( 'noname'
)->text() );
+ break;
+ case self::WRONG_PLUGIN_PASS:
+- $this->mainLoginForm( $this->msg(
'wrongpassword' )->text() );
++ # Message is handled in the authentication code
+ break;
+ case self::NOT_EXISTS:
+ if( $this->getUser()->isAllowed(
'createaccount' ) ) {
+@@ -1181,6 +1192,47 @@ class LoginForm extends SpecialPage {
+ }
+
+ /**
++ * New function for MediaWikiAuth extension
++ *
++ * @param $username mixed username to check
++ * @return bool
++ */
++ public static function checkImportableUser( $username ) {
++ $dbr = wfGetDB( DB_SLAVE );
++
++ # Check against existing users
++ if ( $dbr->tableExists( 'user' ) ) {
++ $res = $dbr->select(
++ 'user',
++ array( 'user_id' ),
++ array( 'user_name' => $username ),
++ __METHOD__
++ );
++ $row = $dbr->fetchObject( $res );
++ # Check for valid id to see if user already exists;
stop if it does
++ # In theory, anyway.
++ if ( $row > 0 ) {
++ return false;
++ }
++
++ # Let's see if the count of revisiosn by their name is
greater than 1
++ # This is not 100% correct as it possible to have a
username
++ # like greenReaper, enter greenreaper and match
++ # However, we're just checking to see if we should even
try, here
++ $revisions = $dbr->selectField(
++ 'revision',
++ 'COUNT(1)',
++ array( 'rev_user_text' => $username ),
++ __METHOD__
++ );
++ if ( $revisions ) {
++ return true;
++ }
++ }
++ return false;
++ }
++
++ /**
+ * @private
+ *
+ * @param $user User
--
To view, visit https://gerrit.wikimedia.org/r/87918
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I04bd4398daf31d2f07825db17819e6654a8f3466
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/MediaWikiAuth
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
Gerrit-Reviewer: Daniel Friesen <[email protected]>
Gerrit-Reviewer: Isarra <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits