How to change Mediawiki 1.19.1 landing page to go to Special: UserLogin

I am trying to set up a private instance of Mediawiki that expects users to log in to see some content. I tried to set up the $ wgWhitelistRead variable in the Localsettings.php file, but it still brings me to a page that says "Login Required". I want the wiki to redirect to Special: userLogin if the user is not logged in. How to do it?

I found a similar question on mwforums , but it seems to be for an older version of mediawiki. Any ideas?

+7
source share
2 answers

Apparently, the natural place for this would be in OutputPage :: showPermissionsErrorPage () . In particular, the actual error message is displayed in the following two lines:

$this->prepareErrorPage( $this->msg( 'loginreqtitle' ) ); $this->addHTML( $this->msg( $msg )->rawParams( $loginLink )->parse() ); 

To redirect directly to Special: UserLogin, you can replace them with something like this (unverified!) Code:

 $this->redirect( SpecialPage::getTitleFor( 'Userlogin' )->getFullURL( $query ) ); 

Alas, there seems to be no convenient hook that allows you to do this from the extension, so it seems like you have to resort to fixing the code. This looks like a natural place for a hook, so it might not be a bad idea to write down a function request to add such a hook.

(Alternatively, you can actually bring the login form into place, but it can be a little more difficult to implement than just redirecting to Special: UserLogin. At first glance, I could not find a convenient method "outputLoginForm ()" for calling Special: UserLogin code , and while it’s actually not difficult to create an appropriate login form yourself, this means that any subsequent changes to the form may violate compatibility.)

+11
source

As a particularly terrible hack, you can put the login form in the message displayed when you need to log in (this should be the loginreqpagetext message). This would not be trivial due to CSRF protection, but you can get around this through AJAX. (There are certainly much better solutions, this is just a quick and dirty way to do this.)

+1
source

All Articles