[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Site 5 * @subpackage com_users 6 * 7 * @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org> 8 * @license GNU General Public License version 2 or later; see LICENSE.txt 9 */ 10 11 namespace Joomla\Component\Users\Site\Controller; 12 13 use Joomla\CMS\Language\Text; 14 use Joomla\CMS\MVC\Controller\BaseController; 15 use Joomla\CMS\Router\Route; 16 17 // phpcs:disable PSR1.Files.SideEffects 18 \defined('_JEXEC') or die; 19 // phpcs:enable PSR1.Files.SideEffects 20 21 /** 22 * Reset controller class for Users. 23 * 24 * @since 1.6 25 */ 26 class ResetController extends BaseController 27 { 28 /** 29 * Method to request a password reset. 30 * 31 * @return boolean 32 * 33 * @since 1.6 34 */ 35 public function request() 36 { 37 // Check the request token. 38 $this->checkToken('post'); 39 40 $app = $this->app; 41 42 /** @var \Joomla\Component\Users\Site\Model\ResetModel $model */ 43 $model = $this->getModel('Reset', 'Site'); 44 $data = $this->input->post->get('jform', array(), 'array'); 45 46 // Submit the password reset request. 47 $return = $model->processResetRequest($data); 48 49 // Check for a hard error. 50 if ($return instanceof \Exception && JDEBUG) { 51 // Get the error message to display. 52 if ($app->get('error_reporting')) { 53 $message = $return->getMessage(); 54 } else { 55 $message = Text::_('COM_USERS_RESET_REQUEST_ERROR'); 56 } 57 58 // Go back to the request form. 59 $this->setRedirect(Route::_('index.php?option=com_users&view=reset', false), $message, 'error'); 60 61 return false; 62 } elseif ($return === false && JDEBUG) { 63 // The request failed. 64 // Go back to the request form. 65 $message = Text::sprintf('COM_USERS_RESET_REQUEST_FAILED', $model->getError()); 66 $this->setRedirect(Route::_('index.php?option=com_users&view=reset', false), $message, 'notice'); 67 68 return false; 69 } 70 71 // To not expose if the user exists or not we send a generic message. 72 $message = Text::_('COM_USERS_RESET_REQUEST'); 73 $this->setRedirect(Route::_('index.php?option=com_users&view=reset&layout=confirm', false), $message, 'notice'); 74 75 return true; 76 } 77 78 /** 79 * Method to confirm the password request. 80 * 81 * @return boolean 82 * 83 * @access public 84 * @since 1.6 85 */ 86 public function confirm() 87 { 88 // Check the request token. 89 $this->checkToken('request'); 90 91 $app = $this->app; 92 93 /** @var \Joomla\Component\Users\Site\Model\ResetModel $model */ 94 $model = $this->getModel('Reset', 'Site'); 95 $data = $this->input->get('jform', array(), 'array'); 96 97 // Confirm the password reset request. 98 $return = $model->processResetConfirm($data); 99 100 // Check for a hard error. 101 if ($return instanceof \Exception) { 102 // Get the error message to display. 103 if ($app->get('error_reporting')) { 104 $message = $return->getMessage(); 105 } else { 106 $message = Text::_('COM_USERS_RESET_CONFIRM_ERROR'); 107 } 108 109 // Go back to the confirm form. 110 $this->setRedirect(Route::_('index.php?option=com_users&view=reset&layout=confirm', false), $message, 'error'); 111 112 return false; 113 } elseif ($return === false) { 114 // Confirm failed. 115 // Go back to the confirm form. 116 $message = Text::sprintf('COM_USERS_RESET_CONFIRM_FAILED', $model->getError()); 117 $this->setRedirect(Route::_('index.php?option=com_users&view=reset&layout=confirm', false), $message, 'notice'); 118 119 return false; 120 } else { 121 // Confirm succeeded. 122 // Proceed to step three. 123 $this->setRedirect(Route::_('index.php?option=com_users&view=reset&layout=complete', false)); 124 125 return true; 126 } 127 } 128 129 /** 130 * Method to complete the password reset process. 131 * 132 * @return boolean 133 * 134 * @since 1.6 135 */ 136 public function complete() 137 { 138 // Check for request forgeries 139 $this->checkToken('post'); 140 141 $app = $this->app; 142 143 /** @var \Joomla\Component\Users\Site\Model\ResetModel $model */ 144 $model = $this->getModel('Reset', 'Site'); 145 $data = $this->input->post->get('jform', array(), 'array'); 146 147 // Complete the password reset request. 148 $return = $model->processResetComplete($data); 149 150 // Check for a hard error. 151 if ($return instanceof \Exception) { 152 // Get the error message to display. 153 if ($app->get('error_reporting')) { 154 $message = $return->getMessage(); 155 } else { 156 $message = Text::_('COM_USERS_RESET_COMPLETE_ERROR'); 157 } 158 159 // Go back to the complete form. 160 $this->setRedirect(Route::_('index.php?option=com_users&view=reset&layout=complete', false), $message, 'error'); 161 162 return false; 163 } elseif ($return === false) { 164 // Complete failed. 165 // Go back to the complete form. 166 $message = Text::sprintf('COM_USERS_RESET_COMPLETE_FAILED', $model->getError()); 167 $this->setRedirect(Route::_('index.php?option=com_users&view=reset&layout=complete', false), $message, 'notice'); 168 169 return false; 170 } else { 171 // Complete succeeded. 172 // Proceed to the login form. 173 $message = Text::_('COM_USERS_RESET_COMPLETE_SUCCESS'); 174 $this->setRedirect(Route::_('index.php?option=com_users&view=login', false), $message); 175 176 return true; 177 } 178 } 179 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |