Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -891,10 +891,6 @@ public function cleanUp()

$app = Factory::getApplication();

// Trigger event after joomla update.
// @TODO: The event dispatched twice, here and at the end of current method. One of it should be removed.
$app->getDispatcher()->dispatch('onJoomlaAfterUpdate', new AfterJoomlaUpdateEvent('onJoomlaAfterUpdate'));

// Remove the update package.
$tempdir = $app->get('tmp_path');

Expand Down
27 changes: 26 additions & 1 deletion libraries/src/Application/AdministratorApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,17 @@ protected function doExecute()
* $this->input->getCmd('option'); or $this->input->getCmd('view');
* ex: due of the sef urls
*/
$this->checkUserRequireReset('com_users', 'user', 'edit', 'com_users/user.edit,com_users/user.save,com_users/user.apply,com_login/logout');
$this->checkUserRequiresReset('com_users', 'user', 'edit', [
['option' => 'com_users', 'task' => 'user.edit'],
['option' => 'com_users', 'task' => 'user.save'],
['option' => 'com_users', 'task' => 'user.apply'],
['option' => 'com_users', 'view' => 'captivate'],
['option' => 'com_login', 'task' => 'logout'],
['option' => 'com_users', 'view' => 'methods'],
['option' => 'com_users', 'view' => 'method'],
['option' => 'com_users', 'task' => 'method.add'],
['option' => 'com_users', 'task' => 'method.save'],
]);

// Dispatch the application
$this->dispatch();
Expand Down Expand Up @@ -359,6 +369,21 @@ public function login($credentials, $options = [])

$this->bootComponent('messages')->getMVCFactory()
->createModel('Messages', 'Administrator')->purge($this->getIdentity() ? $this->getIdentity()->id : 0);

if ($result) {
// Check if the user is required to reset their password
$this->checkUserRequiresReset('com_users', 'user', 'edit', [
['option' => 'com_users', 'task' => 'user.edit'],
['option' => 'com_users', 'task' => 'user.save'],
['option' => 'com_users', 'task' => 'user.apply'],
['option' => 'com_users', 'view' => 'captivate'],
['option' => 'com_login', 'task' => 'logout'],
['option' => 'com_users', 'view' => 'methods'],
['option' => 'com_users', 'view' => 'method'],
['option' => 'com_users', 'task' => 'method.add'],
['option' => 'com_users', 'task' => 'method.save'],
]);
}
}

return $result;
Expand Down
71 changes: 60 additions & 11 deletions libraries/src/Application/CMSApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,46 @@ public function execute()
* @return void
*
* @throws \Exception
* @deprecated __DEPLOY_VERSION__ will be removed in 7.0
* Use $this->checkUserRequiresReset() instead.
*/
protected function checkUserRequireReset($option, $view, $layout, $tasks)
{
$name = $this->getName();
$urls = [];

if ($this->get($name . '_reset_password_override', 0)) {
$tasks = $this->get($name . '_reset_password_tasks', '');
}

// Check task
if (!empty($tasks)) {
$tasks = explode(',', $tasks);

foreach ($tasks as $task) {
[$option, $t] = explode('/', $task);
$urls[] = ['option' => $option, 'task' => $t];
}
}

$this->checkUserRequiresReset($option, $view, $layout, $urls);
}

/**
* Check if the user is required to reset their password.
*
* If the user is required to reset their password will be redirected to the page that manage the password reset.
*
* @param string $option The option that manage the password reset
* @param string $view The view that manage the password reset
* @param string $layout The layout of the view that manage the password reset
* @param array $urls Multi-dimensional array of permitted urls. Ex: [['option' => 'com_users', 'view' => 'profile'],...]
*
* @return void
*
* @throws \Exception
*/
protected function checkUserRequiresReset($option, $view, $layout, $urls = [])
{
if ($this->getIdentity()->requireReset) {
$redirect = false;
Expand All @@ -383,23 +421,34 @@ protected function checkUserRequireReset($option, $view, $layout, $tasks)
$option = $this->get($name . '_reset_password_option', '');
$view = $this->get($name . '_reset_password_view', '');
$layout = $this->get($name . '_reset_password_layout', '');
$tasks = $this->get($name . '_reset_password_tasks', '');
$urls = $this->get($name . '_reset_password_urls', $urls);
}

$task = $this->input->getCmd('task', '');
// If the current URL matches an entry in $urls, we do not redirect
if (\count($urls)) {
$found = false;

foreach ($urls as $url) {
$found2 = false;

// Check task or option/view/layout
if (!empty($task)) {
$tasks = explode(',', $tasks);
foreach ($url as $key => $value) {
if ($this->input->getCmd($key) !== $value) {
$found2 = false;
break;
}

$found2 = true;
}

// Check full task version "option/task"
if (array_search($this->input->getCmd('option', '') . '/' . $task, $tasks) === false) {
// Check short task version, must be on the same option of the view
if ($this->input->getCmd('option', '') !== $option || array_search($task, $tasks) === false) {
// Not permitted task
$redirect = true;
if ($found2) {
$found = true;
break;
}
}

if (!$found) {
$redirect = true;
}
} else {
if (
$this->input->getCmd('option', '') !== $option || $this->input->getCmd('view', '') !== $view
Expand Down
35 changes: 33 additions & 2 deletions libraries/src/Application/SiteApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,19 @@ protected function doExecute()
* $this->input->getCmd('option'); or $this->input->getCmd('view');
* ex: due of the sef urls
*/
$this->checkUserRequireReset('com_users', 'profile', 'edit', 'com_users/profile.save,com_users/profile.apply,com_users/user.logout');
$this->checkUserRequiresReset('com_users', 'profile', 'edit', [
['option' => 'com_users', 'task' => 'profile.save'],
['option' => 'com_users', 'task' => 'profile.apply'],
['option' => 'com_users', 'task' => 'user.logout'],
['option' => 'com_users', 'task' => 'user.menulogout'],
['option' => 'com_users', 'task' => 'captive.validate'],
['option' => 'com_users', 'view' => 'captive'],
['option' => 'com_users', 'view' => 'methods'],
['option' => 'com_users', 'view' => 'method'],
['option' => 'com_users', 'task' => 'method.add'],
['option' => 'com_users', 'task' => 'method.save'],
['option' => 'com_users', 'view' => 'profile', 'layout' => 'edit'],
]);
}

// Dispatch the application
Expand Down Expand Up @@ -664,7 +676,26 @@ public function login($credentials, $options = [])
// Set the access control action to check.
$options['action'] = 'core.login.site';

return parent::login($credentials, $options);
$result = parent::login($credentials, $options);

if (!($result instanceof \Exception) && $result) {
// Check if the user is required to reset their password
$this->checkUserRequiresReset('com_users', 'profile', 'edit', [
['option' => 'com_users', 'task' => 'profile.save'],
['option' => 'com_users', 'task' => 'profile.apply'],
['option' => 'com_users', 'task' => 'user.logout'],
['option' => 'com_users', 'task' => 'user.menulogout'],
['option' => 'com_users', 'task' => 'captive.validate'],
['option' => 'com_users', 'view' => 'captive'],
['option' => 'com_users', 'view' => 'methods'],
['option' => 'com_users', 'view' => 'method'],
['option' => 'com_users', 'task' => 'method.add'],
['option' => 'com_users', 'task' => 'method.save'],
['option' => 'com_users', 'view' => 'profile', 'layout' => 'edit'],
]);
}

return $result;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Console/ExtensionRemoveCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ protected function doExecute(InputInterface $input, OutputInterface $output): in

$response = $this->ioStyle->ask('Are you sure you want to remove this extension?', 'yes/no');

if (strtolower($response) === 'yes') {
if ((strtolower($response) === 'yes') || $input->getOption('no-interaction')) {
// Get an installer object for the extension type
$installer = Installer::getInstance();
$row = new Extension($this->getDatabase());
Expand Down
1 change: 1 addition & 0 deletions libraries/src/Installer/Adapter/ComponentAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,7 @@ public function refreshManifestCache()
$manifest_details = Installer::parseXMLInstallFile($this->parent->getPath('manifest'));
$this->parent->extension->manifest_cache = json_encode($manifest_details);
$this->parent->extension->name = $manifest_details['name'];
$this->parent->extension->changelogurl = $manifest_details['changelogurl'];

// Namespace is optional
if (isset($manifest_details['namespace'])) {
Expand Down
1 change: 1 addition & 0 deletions libraries/src/Installer/Adapter/FileAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@ public function refreshManifestCache()
$manifest_details = Installer::parseXMLInstallFile($this->parent->getPath('manifest'));
$this->parent->extension->manifest_cache = json_encode($manifest_details);
$this->parent->extension->name = $manifest_details['name'];
$this->parent->extension->changelogurl = $manifest_details['changelogurl'];

try {
return $this->parent->extension->store();
Expand Down
2 changes: 2 additions & 0 deletions libraries/src/Installer/Adapter/LanguageAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -734,9 +734,11 @@ public function refreshManifestCache()

$this->parent->manifest = $this->parent->isManifest($manifestPath);
$this->parent->setPath('manifest', $manifestPath);

$manifest_details = Installer::parseXMLInstallFile($this->parent->getPath('manifest'));
$this->parent->extension->manifest_cache = json_encode($manifest_details);
$this->parent->extension->name = $manifest_details['name'];
$this->parent->extension->changelogurl = $manifest_details['changelogurl'];

if ($this->parent->extension->store()) {
return true;
Expand Down
1 change: 1 addition & 0 deletions libraries/src/Installer/Adapter/LibraryAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ public function refreshManifestCache()
$manifest_details = Installer::parseXMLInstallFile($this->parent->getPath('manifest'));
$this->parent->extension->manifest_cache = json_encode($manifest_details);
$this->parent->extension->name = $manifest_details['name'];
$this->parent->extension->changelogurl = $manifest_details['changelogurl'];

try {
return $this->parent->extension->store();
Expand Down
2 changes: 2 additions & 0 deletions libraries/src/Installer/Adapter/ModuleAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,11 @@ public function refreshManifestCache()
$manifestPath = $client->path . '/modules/' . $this->parent->extension->element . '/' . $this->parent->extension->element . '.xml';
$this->parent->manifest = $this->parent->isManifest($manifestPath);
$this->parent->setPath('manifest', $manifestPath);

$manifest_details = Installer::parseXMLInstallFile($this->parent->getPath('manifest'));
$this->parent->extension->manifest_cache = json_encode($manifest_details);
$this->parent->extension->name = $manifest_details['name'];
$this->parent->extension->changelogurl = $manifest_details['changelogurl'];

if ($this->parent->extension->store()) {
return true;
Expand Down
5 changes: 4 additions & 1 deletion libraries/src/Installer/Adapter/PackageAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,6 @@ protected function storeExtension()
$this->extension->name = $this->name;
$this->extension->type = 'package';
$this->extension->element = $this->element;
$this->extension->changelogurl = $this->changelogurl;

// There is no folder for packages
$this->extension->folder = '';
Expand All @@ -552,6 +551,9 @@ protected function storeExtension()
$this->extension->params = $this->parent->getParams();
}

// Update changelogurl
$this->extension->changelogurl = $this->changelogurl;

// Update the manifest cache for the entry
$this->extension->manifest_cache = $this->parent->generateManifestCache();

Expand Down Expand Up @@ -717,6 +719,7 @@ public function refreshManifestCache()
$manifest_details = Installer::parseXMLInstallFile($this->parent->getPath('manifest'));
$this->parent->extension->manifest_cache = json_encode($manifest_details);
$this->parent->extension->name = $manifest_details['name'];
$this->parent->extension->changelogurl = $manifest_details['changelogurl'];

try {
return $this->parent->extension->store();
Expand Down
5 changes: 3 additions & 2 deletions libraries/src/Installer/Adapter/PluginAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -611,10 +611,11 @@ public function refreshManifestCache()
. $this->parent->extension->element . '.xml';
$this->parent->manifest = $this->parent->isManifest($manifestPath);
$this->parent->setPath('manifest', $manifestPath);

$manifest_details = Installer::parseXMLInstallFile($this->parent->getPath('manifest'));
$this->parent->extension->manifest_cache = json_encode($manifest_details);

$this->parent->extension->name = $manifest_details['name'];
$this->parent->extension->name = $manifest_details['name'];
$this->parent->extension->changelogurl = $manifest_details['changelogurl'];

if ($this->parent->extension->store()) {
return true;
Expand Down
1 change: 1 addition & 0 deletions libraries/src/Installer/Adapter/TemplateAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,7 @@ public function refreshManifestCache()
$manifest_details = Installer::parseXMLInstallFile($this->parent->getPath('manifest'));
$this->parent->extension->manifest_cache = json_encode($manifest_details);
$this->parent->extension->name = $manifest_details['name'];
$this->parent->extension->changelogurl = $manifest_details['changelogurl'];

try {
return $this->parent->extension->store();
Expand Down
13 changes: 7 additions & 6 deletions libraries/src/Installer/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2311,12 +2311,13 @@ public static function parseXMLInstallFile($path)
$data['creationDate'] = ((string) $xml->creationDate) ?: Text::_('JLIB_UNKNOWN');
$data['author'] = ((string) $xml->author) ?: Text::_('JLIB_UNKNOWN');

$data['copyright'] = (string) $xml->copyright;
$data['authorEmail'] = (string) $xml->authorEmail;
$data['authorUrl'] = (string) $xml->authorUrl;
$data['version'] = (string) $xml->version;
$data['description'] = (string) $xml->description;
$data['group'] = (string) $xml->group;
$data['copyright'] = (string) $xml->copyright;
$data['authorEmail'] = (string) $xml->authorEmail;
$data['authorUrl'] = (string) $xml->authorUrl;
$data['version'] = (string) $xml->version;
$data['description'] = (string) $xml->description;
$data['group'] = (string) $xml->group;
$data['changelogurl'] = (string) $xml->changelogurl;

// Child template specific fields.
if (isset($xml->inheritable)) {
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ public function onAfterRoute()
($option == 'com_users' && $isAllowedUserTask)
|| ($option == 'com_content' && $view == 'article' && $id == $privacyArticleId)
|| ($option == 'com_users' && $view == 'profile' && $layout == 'edit')
|| ($option == 'com_users' && $view == 'captive')
) {
return;
}
Expand Down