- md5
- 50725e53d8cb89d8ec3ca27ed8ce9cb5
- sha1
- c826dfe40a9454a796da2ccbf0ee5966436c8363
- sha256
- 0ed97eb90f4cc6a20b6d98b06987dcab3eb2a664d014505d8436b3ed519305f3
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright (C) 2021 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Users\Administrator\Dispatcher;
\defined('_JEXEC') or die;
use Joomla\CMS\Dispatcher\ComponentDispatcher;
/**
* ComponentDispatcher class for com_users
*
* @since 4.0.0
*/
class Dispatcher extends ComponentDispatcher
{
/**
* Override checkAccess to allow users edit profile without having to have core.manager permission
*
* @return void
*
* @since 4.0.0
*/
protected function checkAccess()
{
$task = $this->input->getCmd('task');
$view = $this->input->getCmd('view');
$layout = $this->input->getCmd('layout');
$allowedTasks = ['user.edit', 'user.apply', 'user.save', 'user.cancel'];
// Allow users to edit their own account
if (in_array($task, $allowedTasks, true) || ($view === 'user' && $layout === 'edit'))
{
$user = $this->app->getIdentity();
$id = $this->input->getInt('id');
if ((int) $user->id === $id)
{
return;
}
}
/**
* Special case: Multi-factor Authentication
*
* We allow access to all MFA views and tasks. Access control for MFA tasks is performed in
* the Controllers since what is allowed depends on who is logged in and whose account you
* are trying to modify. Implementing these checks in the Dispatcher would violate the
* separation of concerns.
*/
$allowedViews = ['callback', 'captive', 'method', 'methods'];
$isAllowedTask = array_reduce(
$allowedViews,
function ($carry, $taskPrefix) use ($task)
{
return $carry || strpos($task, $taskPrefix . '.') === 0;
},
false
);
if (in_array(strtolower($view), $allowedViews) || $isAllowedTask)
{
return;
}
parent::checkAccess();
}
}
No other release has this exact content. See every version of this file.