简体   繁体   English

Joomla后端登录组件

[英]Joomla Backend Login Component

I'm currently trying to get a custom component working to log a user into the backend given their username and password. 我目前正在尝试让自定义组件正常工作,以便在给定用户名和密码的情况下将用户登录到后端。 I realize the inherent security problems this may present, but I would really like an answer to this problem I've been struggling with. 我意识到这可能会带来固有的安全性问题,但是我真的很想解决我一直在努力解决的这个问题。 Here is the code in my controller.php: 这是我的controller.php中的代码:

function execute() {
    $credentials = array( 'username' => $this->username, 
        'password' => $this->password );
    $options = array();
    $options['group'] = 'Public Backend';
    $options['autoregister'] = false;
    $options['action'] = 'core.login.admin';
    $app =& JFactory::getApplication('administrator');
    $result = $app->login($credentials, $options);
    echo $result;
}

All the documentation that I've read says that this should work (even though it is not exactly kosher to perform admin tasks--like logging into the backend--from a non-admin context). 我阅读的所有文档都说这应该有效(即使从非管理员上下文执行管理员任务(例如登录到后端)并不是完全正确的做法)。 Any idea on what I'm not getting? 对我没有得到的任何想法吗?

EDIT: I forgot to mention which Joomla version I'm using: 2.5.14 编辑:我忘了提到我正在使用哪个Joomla版本:2.5.14

I think you need to pay attention to the Joomla authentication/login/authorization flow and user flow which are managed via user and authentication plugins. 我认为您需要注意通过用户和身份验证插件管理的Joomla身份验证/登录/授权流程和用户流程。 From what you say it sounds like you will still be using the Joomla user table, is that right? 从您所说的看来,您仍将使用Joomla用户表,对吗? So in that case the Joomla user plugin should work. 因此,在这种情况下,Joomla用户插件应该可以使用。

Assuming that is true you want to make an authentication plugin. 假设这是真的,您想制作一个身份验证插件。 This plugin will be checked along with the joomla authentication plugin and any other authentication plugins you may have running (eg remember me/cookie login). 该插件将与joomla认证插件以及您可能正在运行的任何其他认证插件(例如,记住我/ Cookie登录名)一起进行检查。

I don't totally understand what you are trying to do (and you haven't said what version of Joomla you are on, which makes a difference in this case), for example do you really want to login to the full back end or do you just want to show some screens the way the insert image plugin does? 我不完全了解您要做什么(并且您还没有说您正在使用的Joomla版本,在这种情况下会有所不同),例如,您是否真的要登录到完整的后端或您是否只想以插入图像插件的方式显示一些屏幕? If on Joomla 3 you might want to look at the Google Summer of Code project for bringing some admin to the front end (called com_services for now). 如果在Joomla 3上,您可能需要查看Google Summer of Code项目,以将一些管理员带到前端(现在称为com_services)。 That student also has an http login plugin you could look at. 该学生还有一个可以查看的http登录插件。 https://github.com/Buddhima/Joomla-HttpLogin-plugin https://github.com/Buddhima/Joomla-HttpLogin-plugin

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM