Use AuthManager on special pages
[lhc/web/wiklou.git] / includes / specialpage / SpecialPageFactory.php
index 4c869f9..45c5f7d 100644 (file)
@@ -81,18 +81,23 @@ class SpecialPageFactory {
                'PagesWithProp' => 'SpecialPagesWithProp',
                'TrackingCategories' => 'SpecialTrackingCategories',
 
-               // Login/create account
-               'Userlogin' => 'LoginForm',
-               'CreateAccount' => 'SpecialCreateAccount',
+               // Authentication
+               'Userlogin' => 'SpecialUserLogin',
+               'Userlogout' => 'SpecialUserLogoutPreAuthManager',
+               'CreateAccount' => 'SpecialCreateAccountPreAuthManager',
+               'LinkAccounts' => 'SpecialLinkAccounts',
+               'UnlinkAccounts' => 'SpecialUnlinkAccounts',
+               'ChangeCredentials' => 'SpecialChangeCredentials',
+               'RemoveCredentials' => 'SpecialRemoveCredentials',
 
                // Users and rights
                'Activeusers' => 'SpecialActiveUsers',
                'Block' => 'SpecialBlock',
                'Unblock' => 'SpecialUnblock',
                'BlockList' => 'SpecialBlockList',
-               'ChangePassword' => 'SpecialChangePassword',
+               'ChangePassword' => 'SpecialChangePasswordPreAuthManager',
                'BotPasswords' => 'SpecialBotPasswords',
-               'PasswordReset' => 'SpecialPasswordReset',
+               'PasswordReset' => 'SpecialPasswordResetPreAuthManager',
                'DeletedContributions' => 'DeletedContributionsPage',
                'Preferences' => 'SpecialPreferences',
                'ResetTokens' => 'SpecialResetTokens',
@@ -178,7 +183,6 @@ class SpecialPageFactory {
                'Revisiondelete' => 'SpecialRevisionDelete',
                'RunJobs' => 'SpecialRunJobs',
                'Specialpages' => 'SpecialSpecialpages',
-               'Userlogout' => 'SpecialUserlogout',
        ];
 
        private static $list;
@@ -226,6 +230,7 @@ class SpecialPageFactory {
                global $wgDisableInternalSearch, $wgEmailAuthentication;
                global $wgEnableEmail, $wgEnableJavaScriptTest;
                global $wgPageLanguageUseDB, $wgContentHandlerUseDB;
+               global $wgDisableAuthManager;
 
                if ( !is_array( self::$list ) ) {
 
@@ -241,7 +246,7 @@ class SpecialPageFactory {
                        }
 
                        if ( $wgEnableEmail ) {
-                               self::$list['ChangeEmail'] = 'SpecialChangeEmail';
+                               self::$list['ChangeEmail'] = 'SpecialChangeEmailPreAuthManager';
                        }
 
                        if ( $wgEnableJavaScriptTest ) {
@@ -255,6 +260,19 @@ class SpecialPageFactory {
                                self::$list['ChangeContentModel'] = 'SpecialChangeContentModel';
                        }
 
+                       // horrible hack to allow selection between old and new classes via a feature flag - T110756
+                       // will be removed once AuthManager is stable
+                       if ( !$wgDisableAuthManager ) {
+                               self::$list = array_map( function ( $class ) {
+                                       return preg_replace( '/PreAuthManager$/', '', $class );
+                               }, self::$list );
+                       } else {
+                               self::$list['Userlogin'] = 'LoginForm';
+                               self::$list = array_diff_key( self::$list, array_fill_keys( [
+                                       'LinkAccounts', 'UnlinkAccounts', 'ChangeCredentials', 'RemoveCredentials',
+                               ], true ) );
+                       }
+
                        // Add extension special pages
                        self::$list = array_merge( self::$list, $wgSpecialPages );