错误的登录尝试后,Joomla 3重定向 [英] Joomla 3 redirect after wrong login try
问题描述
我使用Joomla的登录模块.登录和注销重定向到模块设置中设置的页面.
Iam using the login module of Joomla. Login and Logout redirects to the pages which are set in the modul settings.
我的问题是用户尝试使用错误的用户凭据登录的状态.在这种情况下,用户将被重定向到component/users/?view = login页面.就我而言,此页面未使用,并且也没有像其余页面一样设计.因此,在错误的登录后,我想将用户重定向到上一页.
My problem is the status, where a user tries to login with wrong user credentials. In this case, the user will be redirected to component/users/?view=login page. In my case, this page is not in use and also not designed like the rest of the pages. Therefore I would like to redirect the user, after a wrong login, to the previous page.
有人知道如何解决吗?
thx
推荐答案
您将需要修改用户控制器.但是要使其保持更新证明",您不能修改核心代码,这就是我们进行覆盖的原因:
You will need to modify users controller. But to keep it "update proof" you cannot modify the core code, thats why we will make an override:
- 转到
components/com_users/controllers/
并复制一个名为user.php
的文件,您可以调用一个新文件user2.php
- 打开
user2.php
文件,并将控制器类重命名为UsersControllerUser2
- 为您的登录模块创建一个模板替代(也要使其具有更新证明),创建一个
templates/YOUR_TEMPLATE/html/mod_login
文件夹,然后在其中复制modules/mod_login/tmpl/default.php
文件. - 打开在步骤3中创建的文件,并将登录模块任务从
<input type="hidden" name="task" value="user.login" />
更改为<input type="hidden" name="task" value="user2.login" />
- 再次打开user2.php文件,并修改这部分代码(约77-82行):
- Go to the
components/com_users/controllers/
and duplicate a file calleduser.php
, you can call a new fileuser2.php
- Open
user2.php
file and rename controller class toUsersControllerUser2
- Create a template override of your login module (to make it update proof also), create a
templates/YOUR_TEMPLATE/html/mod_login
folder and copymodules/mod_login/tmpl/default.php
file there. - Open file created in step 3 and change login module task from
<input type="hidden" name="task" value="user.login" />
to<input type="hidden" name="task" value="user2.login" />
- Open user2.php file once again, and modify this part of code (around lines 77-82):
$ app-> redirect(JRoute :: _('index.php?option = com_users& view = login', 错误));
$app->redirect(JRoute::_('index.php?option=com_users&view=login', false));
将$app->redirect
路线更改为您想要的任何地方:)
Change $app->redirect
route to whatever you want :)
这篇关于错误的登录尝试后,Joomla 3重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!