- md5
- bce2dc11da11ed209f42a46fd8417305
- sha1
- cd39946eaa5c6f16354b0f7766fcc4513d5fed0b
- sha256
- 8cae3e7c61c351b8f9fe5d482e5890eae455f0ef09e9dd654a50c0ae05bd85e8
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
<?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;
use Joomla\CMS\Dispatcher\ComponentDispatcher;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* 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'];
// If the user editing layout is called, we assume its the user.edit task
if (!$task && $view === 'user' && $layout === 'edit') {
$task = 'user.edit';
}
// 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 || str_starts_with($task ?? '', $taskPrefix . '.');
},
false
);
if (\in_array(strtolower($view ?? ''), $allowedViews) || $isAllowedTask) {
return;
}
parent::checkAccess();
}
}
The same content is in 15 releases, Joomla 5.4.6 to 6.2.0-alpha3. See them all, or every version of this file.