简体   繁体   English

了解Joomla默认登录

[英]Understanding Joomla default login

I'm fairly new to Joomla and Php in general. 一般而言,我对Joomla和Php还是陌生的。 I need to understand how does Joomla perform login operation (via php code). 我需要了解Joomla如何执行登录操作(通过php代码)。 The following is the php snippet that performs the operation: 以下是执行该操作的php代码段:

<form action="<?php echo JRoute::_('index.php?option=com_users&task=user.login'); ?>" method="post">

        <fieldset>
            <?php foreach ($this->form->getFieldset('credentials') as $field): ?>
                <?php if (!$field->hidden): ?>
                    <div class="login-fields"><?php echo $field->label; ?>
                    <?php echo $field->input; ?></div>
                <?php endif; ?>
            <?php endforeach; ?>
            <?php if (JPluginHelper::isEnabled('system', 'remember')) : ?>
            <div class="login-fields">
                <label id="remember-lbl" for="remember"><?php echo JText::_('JGLOBAL_REMEMBER_ME') ?></label>
                <input id="remember" type="checkbox" name="remember" class="inputbox" value="yes"  alt="<?php echo JText::_('JGLOBAL_REMEMBER_ME') ?>" />
            </div>
            <?php endif; ?>
        <button type="submit" class="button"><?php echo JText::_('JLOGIN'); ?></button>
            <input type="hidden" name="return" value="<?php echo base64_encode($this->params->get('login_redirect_url', $this->form->getValue('return'))); ?>" />
            <?php echo JHtml::_('form.token'); ?>
        </fieldset>
    </form>

To my understanding, the first line perform POST request to post username and password to the server. 据我了解,第一行执行POST请求以将用户名和密码发布到服务器。 In addition, a session token, should be retrieved upon successful validation. 此外,成功验证后应检索会话令牌。 However, I could not figure out where exactly are the username and the password (that are inserted by the user and supposed to be sent via POST request) in this line. 但是,我无法弄清楚此行中的用户名和密码(由用户插入并应通过POST请求发送)的确切位置。 Or, where are they retrieved from? 或者,它们是从哪里找来的? In addition, where is the response content (session Token) is stored? 另外,响应内容(会话令牌)存储在哪里?

My objective is to mimic the request using JavaScript so that I can perform login using external mobile App. 我的目标是使用JavaScript模仿请求,以便我可以使用外部移动应用执行登录。 In other words, I need to write the same logic in JavaScript so I can login to the website from mobile App. 换句话说,我需要用JavaScript编写相同的逻辑,以便可以从移动应用程序登录网站。

The fields are retrieved from login.xml file from the following path \\components\\com_users\\models\\forms. 这些字段是从login.xml文件中的以下路径\\ components \\ com_users \\ models \\ forms中检索的。 getFieldset('credentials') will get field details of the fieldset in the name "credentials" <fieldset name="credentials" in the above mentioned file.And you can use foreach to display the field. getFieldset('credentials')将在上述文件中以名称“ credentials” <fieldset name="credentials"获得字段集的字段详细信息。您可以使用foreach显示该字段。 You can refer this link for more info. 您可以参考此链接以获取更多信息。

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

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