简体   繁体   English

如何更改Mediawiki 1.19.1的登录页面以直接转到Special:UserLogin

[英]How can I change the landing page of Mediawiki 1.19.1 to directly go to Special:UserLogin

I am trying to setup a private Mediawiki instance which expects users to login to see any content. 我正在尝试设置一个私有的Mediawiki实例,希望用户登录以查看任何内容。 I tried tweaking the $wgWhitelistRead variable in the Localsettings.php file but it still takes me to a page that says, "Login Required". 我尝试在Localsettings.php文件中调整$ wgWhitelistRead变量,但它仍然会将我带到一个页面,上面写着“需要登录”。 I want the wiki to redirect to Special:userLogin if a user is not logged in. How do I do this? 如果用户没有登录,我希望wiki重定向到Special:userLogin。我该怎么办?

I found a similar question on the mwforums but it seems to be for an older version of mediawiki. 在mwforums上发现了类似的问题,但似乎是旧版本的mediawiki。 Any ideas? 有任何想法吗?

The seemingly natural place to do this would be in OutputPage::showPermissionsErrorPage() . 看似自然的地方是OutputPage :: showPermissionsErrorPage() Specifically, 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 could replace them with something like this (untested!) code: 要直接重定向到Special:UserLogin,您可以使用类似这样的(未经测试的!)代码替换它们:

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

Alas, there doesn't seem to be any convenient hook in place that would let you do this from an extension, so it looks like you'll have to resort to patching the code. 唉,似乎没有任何方便的钩子可以让你从扩展中执行此操作,所以看起来你不得不求助于修补代码。 This does look like a natural place for a hook, so it might not be a bad idea to file a feature request asking that such a hook be added. 这看起来像一个钩子的自然位置,因此提交一个要求添加这样一个钩子的功能请求可能不是一个坏主意。

(Alternatively, you could indeed output a login form in place, but that might be a bit trickier to implement than just redirecting to Special:UserLogin. At a glance, I couldn't find any convenient "outputLoginForm()" method to call in the Special:UserLogin code , and while it's not actually hard to generate a matching login form yourself, that would mean that any later changes to the form might break compatibility.) (或者,您确实可以输出一个登录表单,但实现起来可能比仅重定向到Special:UserLogin有点棘手。乍一看,我找不到任何方便的“outputLoginForm()”方法来调用Special:UserLogin代码 ,虽然实际上并不难自己生成匹配的登录表单,但这意味着对表单的任何后续更改都可能会破坏兼容性。)

As a particularly horrible hack, you could put the login form into the message displayed when login is needed (that should be the loginreqpagetext message). 作为一个特别可怕的黑客,您可以将登录表单放入需要登录时显示的消息(应该是loginreqpagetext消息)。 It would be non-trivial due to the anti-CSRF protection, but you can work around that via AJAX. 由于反CSRF保护,这将是非平凡的,但您可以通过AJAX解决这个问题。 (There are surely much better solutions; this is just the quick and dirty way of doing it.) (肯定有更好的解决方案;这只是快速而肮脏的方式。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在MW 1.28中编辑MediaWiki的Special:UserLogin页面的HTML? - How do you edit the HTML for MediaWiki's Special:UserLogin page in MW 1.28? Laravel成功登录后如何更改登录页面? - How can I change the landing page after a success Laravel login? 我如何更改JavaScript的输出以直接转到另一个页面而不是警报窗口? - how can i change the output of JavaScript to go to directly to another page instead of an alert window? 如何隐藏或删除由 MediaWIki 提供支持的特殊页面的 div class? - How can I hide or remove a div class of a special page powered by MediaWIki? 如何让 MediaWiki 忽略来自 Recommind 的页面浏览量? - How can I get MediaWiki to ignore page views from Recommind? 如何进一步在php中为用户登录页面设置Cookie我没有如何访问 - How To Set Cookie in php for userlogin page further I don't how to access 转到网络研讨会自定义登录页面 - Go to webinar custom landing page 我可以直接在PHP中查询MediaWiki语义值(SMW)吗? - Can I query a MediaWiki semantic value (SMW) directly in PHP? 我该如何销毁会话,以使用户无法返回上一页并不能直接在codeigniter中访问该页面? - how can i destroy session so that user cant go back to the previous page and cant access the page directly in codeigniter? 如何检查页面是否直接访问? - How can i check if page accessed directly?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM