Add AuthManager
[lhc/web/wiklou.git] / includes / specials / SpecialUserlogin.php
index 45315a7..11182d4 100644 (file)
@@ -690,7 +690,12 @@ class LoginForm extends SpecialPage {
 
                $status = $u->addToDatabase();
                if ( !$status->isOK() ) {
-                       return $status;
+                       if ( $status->hasMessage( 'userexists' ) ) {
+                               // AuthManager probably just added the user.
+                               $u->saveSettings();
+                       } else {
+                               return $status;
+                       }
                }
 
                if ( $wgAuth->allowPasswordChange() ) {
@@ -702,10 +707,12 @@ class LoginForm extends SpecialPage {
                SessionManager::singleton()->invalidateSessionsForUser( $u );
 
                Hooks::run( 'LocalUserCreated', [ $u, $autocreate ] );
-               $oldUser = $u;
-               $wgAuth->initUser( $u, $autocreate );
-               if ( $oldUser !== $u ) {
-                       wfWarn( get_class( $wgAuth ) . '::initUser() replaced the user object' );
+               if ( $wgAuth && !$wgAuth instanceof MediaWiki\Auth\AuthManagerAuthPlugin ) {
+                       $oldUser = $u;
+                       $wgAuth->initUser( $u, $autocreate );
+                       if ( $oldUser !== $u ) {
+                               wfWarn( get_class( $wgAuth ) . '::initUser() replaced the user object' );
+                       }
                }
 
                $u->saveSettings();
@@ -857,10 +864,12 @@ class LoginForm extends SpecialPage {
                        $this->mAbortLoginErrorMsg = 'resetpass-expired';
                } else {
                        Hooks::run( 'UserLoggedIn', [ $u ] );
-                       $oldUser = $u;
-                       $wgAuth->updateUser( $u );
-                       if ( $oldUser !== $u ) {
-                               wfWarn( get_class( $wgAuth ) . '::updateUser() replaced the user object' );
+                       if ( $wgAuth && !$wgAuth instanceof MediaWiki\Auth\AuthManagerAuthPlugin ) {
+                               $oldUser = $u;
+                               $wgAuth->updateUser( $u );
+                               if ( $oldUser !== $u ) {
+                                       wfWarn( get_class( $wgAuth ) . '::updateUser() replaced the user object' );
+                               }
                        }
                        $wgUser = $u;
                        // This should set it for OutputPage and the Skin
@@ -1817,8 +1826,7 @@ class LoginForm extends SpecialPage {
        }
 
        /**
-        * Private function to check password expiration, until AuthManager comes
-        * along to handle that.
+        * Private function to check password expiration, until this is rewritten for AuthManager.
         * @param User $user
         * @return string|bool
         */