fix: [encryption keys] adding a key correctly returns the expected view elements

- also some minor tweaks on the index
- CRUD component now accepts a redirect parameter

- as reported by cert.pl
pull/32/head
iglocska 2020-11-06 10:25:22 +01:00
parent 2f7624f71c
commit d04efb232c
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
3 changed files with 15 additions and 8 deletions

View File

@ -96,7 +96,11 @@ class CRUDComponent extends Component
$this->Controller->render($params['displayOnSuccess']);
return;
}
$this->Controller->redirect(['action' => 'view', $data->id]);
if (empty($params['redirect'])) {
$this->Controller->redirect(['action' => 'view', $id]);
} else {
$this->Controller->redirect($params['redirect']);
}
}
} else {
$validationMessage = $this->prepareValidationError($data);
@ -194,7 +198,11 @@ class CRUDComponent extends Component
$this->Controller->restResponsePayload = $this->RestResponse->viewData($data, 'json');
} else {
$this->Controller->Flash->success($message);
$this->Controller->redirect(['action' => 'view', $id]);
if (empty($params['redirect'])) {
$this->Controller->redirect(['action' => 'view', $id]);
} else {
$this->Controller->redirect($params['redirect']);
}
}
} else {
$validationMessage = $this->prepareValidationError($data);

View File

@ -37,7 +37,7 @@ class EncryptionKeysController extends AppController
public function add()
{
$this->CRUD->add(['displayOnSuccess' => 'add_success']);
$this->CRUD->add(['redirect' => $this->referer()]);
if ($this->ParamHandler->isRest()) {
return $this->restResponsePayload;
}

View File

@ -35,9 +35,9 @@ echo $this->element('genericElements/IndexTable/index_table', [
'data_path' => 'id',
],
[
'name' => __('Owner type'),
'sort' => 'owner_type',
'data_path' => 'owner_type',
'name' => __('Type'),
'sort' => 'type',
'data_path' => 'type',
],
[
'name' => __('Owner ID'),
@ -64,8 +64,7 @@ echo $this->element('genericElements/IndexTable/index_table', [
],
[
'name' => __('Key'),
'data_path' => 'encryption_key',
'privacy' => 1
'data_path' => 'encryption_key'
],
],
'title' => __('Encryption key Index'),