fix: [localTools:action] Catch error if local tool's action returned unexpected data

cli-modification-summary
Sami Mokaddem 2022-06-08 11:51:52 +02:00
parent d55c1fd5d1
commit 8c4c75d83a
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
2 changed files with 19 additions and 16 deletions

View File

@ -6,6 +6,8 @@ use App\Controller\AppController;
use Cake\Utility\Hash;
use Cake\Utility\Text;
use \Cake\Database\Expression\QueryExpression;
use Cake\Http\Exception\NotFoundException;
use Cake\Http\Exception\MethodNotAllowedException;
class LocalToolsController extends AppController
{
@ -110,6 +112,9 @@ class LocalToolsController extends AppController
$actionDetails = $this->LocalTools->getActionDetails($actionName);
$params['connection'] = $connection;
$results = $this->LocalTools->action($this->ACL->getUser()['id'], $connection->connector, $actionName, $params, $this->request);
if (empty($results)) {
throw new MethodNotAllowedException(__('Could not execute the requested action.'));
}
if (!empty($results['redirect'])) {
$this->redirect($results['redirect']);
}

View File

@ -39,24 +39,22 @@
var url = $('#view-child-body-<?= h($randomId) ?>').data('content-url');
var loadon = $('#view-child-body-<?= h($randomId) ?>').data('load-on');
if (loadon === 'ready') {
$.ajax({
success:function (data, textStatus) {
$('#view-child-body-<?= h($randomId) ?>').html(data);
},
type: "get",
cache: false,
url: url,
});
AJAXApi.quickFetchURL(url, {})
.then((html) => {
$('#view-child-body-<?= h($randomId) ?>').html(html);
})
.catch((err) => {
$('#view-child-body-<?= h($randomId) ?>').text(err.message);
})
} else {
$('#view-child-<?= h($randomId) ?>').on('hidden.bs.collapse', function () {
$.ajax({
success:function (data, textStatus) {
$('#view-child-body-<?= h($randomId) ?>').html(data);
},
type: "get",
cache: false,
url: url,
});
AJAXApi.quickFetchURL(url, {})
.then((html) => {
$('#view-child-body-<?= h($randomId) ?>').html(html);
})
.catch((err) => {
$('#view-child-body-<?= h($randomId) ?>').text(err.message);
})
})
}
});