Source for file user.php
Documentation is available at user.php
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
require_once JPATH_COMPONENT .
'/controller.php';
* Registration controller class for Users.
* Method to log in a user.
// Populate the data array:
$data['return'] =
base64_decode($app->input->post->get('return', '', 'BASE64'));
$data['username'] =
JRequest::getVar('username', '', 'method', 'username');
// Set the return URL if empty.
if (empty($data['return']))
$data['return'] =
'index.php?option=com_users&view=profile';
// Set the return URL in the user state to allow modification by plugins
$app->setUserState('users.login.form.return', $data['return']);
// Get the log in options.
$options['remember'] =
$this->input->getBool('remember', false);
$options['return'] =
$data['return'];
// Get the log in credentials.
$credentials['username'] =
$data['username'];
$credentials['password'] =
$data['password'];
$credentials['secretkey'] =
$data['secretkey'];
if (true ===
$app->login($credentials, $options))
if ($options['remember'] =
true)
$app->setUserState('rememberLogin', true);
$app->setUserState('users.login.form.data', array());
$app->redirect(JRoute::_($app->getUserState('users.login.form.return'), false));
$data['remember'] = (int)
$options['remember'];
$app->setUserState('users.login.form.data', $data);
$app->redirect(JRoute::_('index.php?option=com_users&view=login', false));
* Method to log out a user.
// Check if the log out succeeded.
if (!($error instanceof
Exception))
// Get the return url from the request and validate that it is internal.
$app->redirect(JRoute::_($return, false));
$app->redirect(JRoute::_('index.php?option=com_users&view=login', false));
* Method to register a user.
$data =
$this->input->post->get('user', array(), 'array');
// Get the model and validate the data.
$model =
$this->getModel('Registration', 'UsersModel');
$return =
$model->validate($data);
// Get the validation messages.
$errors =
$model->getErrors();
// Push up to three validation messages out to the user.
for ($i =
0, $n =
count($errors); $i <
$n &&
$i <
3; $i++
)
if ($errors[$i] instanceof
Exception)
$app->enqueueMessage($errors[$i]->getMessage(), 'notice');
$app->enqueueMessage($errors[$i], 'notice');
// Save the data in the session.
$app->setUserState('users.registration.form.data', $data);
// Redirect back to the registration form.
$this->setRedirect('index.php?option=com_users&view=registration');
// Finish the registration.
$return =
$model->register($data);
// Save the data in the session.
$app->setUserState('users.registration.form.data', $data);
// Redirect back to the registration form.
$message =
JText::sprintf('COM_USERS_REGISTRATION_SAVE_FAILED', $model->getError());
$this->setRedirect('index.php?option=com_users&view=registration', $message, 'error');
// Flush the data from the session.
$app->setUserState('users.registration.form.data', null);
* Method to login a user.
// Check the request token.
$model =
$this->getModel('User', 'UsersModel');
$data =
$this->input->post->get('jform', array(), 'array');
// Submit the username remind request.
$return =
$model->processRemindRequest($data);
// Check for a hard error.
if ($return instanceof
Exception)
// Get the error message to display.
if ($app->getCfg('error_reporting'))
$message =
$return->getMessage();
$message =
JText::_('COM_USERS_REMIND_REQUEST_ERROR');
// Get the route to the next page.
$itemid =
$itemid !==
null ?
'&Itemid='.
$itemid :
'';
$route =
'index.php?option=com_users&view=remind'.
$itemid;
// Go back to the complete form.
} elseif ($return ===
false)
// Get the route to the next page.
$itemid =
$itemid !==
null ?
'&Itemid='.
$itemid :
'';
$route =
'index.php?option=com_users&view=remind'.
$itemid;
// Go back to the complete form.
$message =
JText::sprintf('COM_USERS_REMIND_REQUEST_FAILED', $model->getError());
// Get the route to the next page.
$itemid =
$itemid !==
null ?
'&Itemid='.
$itemid :
'';
$route =
'index.php?option=com_users&view=login'.
$itemid;
// Proceed to the login form.
$message =
JText::_('COM_USERS_REMIND_REQUEST_SUCCESS');
* Method to login a user.
// Check for request forgeries
Documentation generated on Tue, 19 Nov 2013 15:16:18 +0100 by phpDocumentor 1.4.3