- md5
- f1bc00609f49a86f7871dced9a8facc4
- sha1
- d19de2c9792d8c54d1ef6f6d5647c1c1ae879fd8
- sha256
- 06064704a7042030b7b9afc2c179315e4c467c89aec25e76f2d8088621251521
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
<?php
/**
* @package Joomla.Site
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
require_once JPATH_COMPONENT . '/controller.php';
/**
* Reset controller class for Users.
*
* @since 1.6
*/
class UsersControllerReset extends UsersController
{
/**
* Method to request a password reset.
*
* @return boolean
*
* @since 1.6
*/
public function request()
{
// Check the request token.
JSession::checkToken('post') or jexit(JText::_('JINVALID_TOKEN'));
$app = JFactory::getApplication();
$model = $this->getModel('Reset', 'UsersModel');
$data = $this->input->post->get('jform', array(), 'array');
// Submit the password reset request.
$return = $model->processResetRequest($data);
// Check for a hard error.
if ($return instanceof Exception)
{
// Get the error message to display.
if ($app->get('error_reporting'))
{
$message = $return->getMessage();
}
else
{
$message = JText::_('COM_USERS_RESET_REQUEST_ERROR');
}
// Get the route to the next page.
$itemid = UsersHelperRoute::getResetRoute();
$itemid = $itemid !== null ? '&Itemid=' . $itemid : '';
$route = 'index.php?option=com_users&view=reset' . $itemid;
// Go back to the request form.
$this->setRedirect(JRoute::_($route, false), $message, 'error');
return false;
}
elseif ($return === false)
{
// The request failed.
// Get the route to the next page.
$itemid = UsersHelperRoute::getResetRoute();
$itemid = $itemid !== null ? '&Itemid=' . $itemid : '';
$route = 'index.php?option=com_users&view=reset' . $itemid;
// Go back to the request form.
$message = JText::sprintf('COM_USERS_RESET_REQUEST_FAILED', $model->getError());
$this->setRedirect(JRoute::_($route, false), $message, 'notice');
return false;
}
else
{
// The request succeeded.
// Get the route to the next page.
$itemid = UsersHelperRoute::getResetRoute();
$itemid = $itemid !== null ? '&Itemid=' . $itemid : '';
$route = 'index.php?option=com_users&view=reset&layout=confirm' . $itemid;
// Proceed to step two.
$this->setRedirect(JRoute::_($route, false));
return true;
}
}
/**
* Method to confirm the password request.
*
* @return boolean
*
* @access public
* @since 1.6
*/
public function confirm()
{
// Check the request token.
JSession::checkToken('request') or jexit(JText::_('JINVALID_TOKEN'));
$app = JFactory::getApplication();
$model = $this->getModel('Reset', 'UsersModel');
$data = $this->input->get('jform', array(), 'array');
// Confirm the password reset request.
$return = $model->processResetConfirm($data);
// Check for a hard error.
if ($return instanceof Exception)
{
// Get the error message to display.
if ($app->get('error_reporting'))
{
$message = $return->getMessage();
}
else
{
$message = JText::_('COM_USERS_RESET_CONFIRM_ERROR');
}
// Get the route to the next page.
$itemid = UsersHelperRoute::getResetRoute();
$itemid = $itemid !== null ? '&Itemid=' . $itemid : '';
$route = 'index.php?option=com_users&view=reset&layout=confirm' . $itemid;
// Go back to the confirm form.
$this->setRedirect(JRoute::_($route, false), $message, 'error');
return false;
}
elseif ($return === false)
{
// Confirm failed.
// Get the route to the next page.
$itemid = UsersHelperRoute::getResetRoute();
$itemid = $itemid !== null ? '&Itemid=' . $itemid : '';
$route = 'index.php?option=com_users&view=reset&layout=confirm' . $itemid;
// Go back to the confirm form.
$message = JText::sprintf('COM_USERS_RESET_CONFIRM_FAILED', $model->getError());
$this->setRedirect(JRoute::_($route, false), $message, 'notice');
return false;
}
else
{
// Confirm succeeded.
// Get the route to the next page.
$itemid = UsersHelperRoute::getResetRoute();
$itemid = $itemid !== null ? '&Itemid=' . $itemid : '';
$route = 'index.php?option=com_users&view=reset&layout=complete' . $itemid;
// Proceed to step three.
$this->setRedirect(JRoute::_($route, false));
return true;
}
}
/**
* Method to complete the password reset process.
*
* @return boolean
*
* @since 1.6
*/
public function complete()
{
// Check for request forgeries
JSession::checkToken('post') or jexit(JText::_('JINVALID_TOKEN'));
$app = JFactory::getApplication();
$model = $this->getModel('Reset', 'UsersModel');
$data = $this->input->post->get('jform', array(), 'array');
// Complete the password reset request.
$return = $model->processResetComplete($data);
// Check for a hard error.
if ($return instanceof Exception)
{
// Get the error message to display.
if ($app->get('error_reporting'))
{
$message = $return->getMessage();
}
else
{
$message = JText::_('COM_USERS_RESET_COMPLETE_ERROR');
}
// Get the route to the next page.
$itemid = UsersHelperRoute::getResetRoute();
$itemid = $itemid !== null ? '&Itemid=' . $itemid : '';
$route = 'index.php?option=com_users&view=reset&layout=complete' . $itemid;
// Go back to the complete form.
$this->setRedirect(JRoute::_($route, false), $message, 'error');
return false;
}
elseif ($return === false)
{
// Complete failed.
// Get the route to the next page.
$itemid = UsersHelperRoute::getResetRoute();
$itemid = $itemid !== null ? '&Itemid=' . $itemid : '';
$route = 'index.php?option=com_users&view=reset&layout=complete' . $itemid;
// Go back to the complete form.
$message = JText::sprintf('COM_USERS_RESET_COMPLETE_FAILED', $model->getError());
$this->setRedirect(JRoute::_($route, false), $message, 'notice');
return false;
}
else
{
// Complete succeeded.
// Get the route to the next page.
$itemid = UsersHelperRoute::getLoginRoute();
$itemid = $itemid !== null ? '&Itemid=' . $itemid : '';
$route = 'index.php?option=com_users&view=login' . $itemid;
// Proceed to the login form.
$message = JText::_('COM_USERS_RESET_COMPLETE_SUCCESS');
$this->setRedirect(JRoute::_($route, false), $message);
return true;
}
}
}
The same content is in 22 releases, Joomla 3.5.0-beta2 to 3.6.2. See them all, or every version of this file.