简体   繁体   中英

Understanding Joomla default login

I'm fairly new to Joomla and Php in general. I need to understand how does Joomla perform login operation (via php code). The following is the php snippet that performs the operation:

<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. 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. 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. In other words, I need to write the same logic in JavaScript so I can login to the website from mobile App.

The fields are retrieved from login.xml file from the following path \\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. You can refer this link for more info.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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