2020-06-21 21:31:30 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Controller;
|
|
|
|
|
|
|
|
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;
|
|
|
|
use Cake\Http\Exception\ForbiddenException;
|
|
|
|
use Cake\Http\Exception\NotAcceptableException;
|
|
|
|
use Cake\Error\Debugger;
|
|
|
|
|
|
|
|
class AuthKeysController extends AppController
|
|
|
|
{
|
|
|
|
public function index()
|
|
|
|
{
|
|
|
|
$this->CRUD->index([
|
2021-01-14 11:33:51 +01:00
|
|
|
'filters' => ['Users.username', 'authkey', 'comment', 'Users.id'],
|
2020-06-21 21:31:30 +02:00
|
|
|
'quickFilters' => ['authkey', 'comment'],
|
2020-08-07 21:47:04 +02:00
|
|
|
'contain' => ['Users'],
|
|
|
|
'exclude_fields' => ['authkey']
|
2020-06-21 21:31:30 +02:00
|
|
|
]);
|
2021-01-11 16:28:07 +01:00
|
|
|
$responsePayload = $this->CRUD->getResponsePayload();
|
|
|
|
if (!empty($responsePayload)) {
|
|
|
|
return $responsePayload;
|
2020-06-21 21:31:30 +02:00
|
|
|
}
|
2020-08-07 21:47:04 +02:00
|
|
|
$this->set('metaGroup', $this->isAdmin ? 'Administration' : 'Cerebrate');
|
2020-06-21 21:31:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function delete($id)
|
|
|
|
{
|
|
|
|
$this->CRUD->delete($id);
|
2021-01-11 16:28:07 +01:00
|
|
|
$responsePayload = $this->CRUD->getResponsePayload();
|
|
|
|
if (!empty($responsePayload)) {
|
|
|
|
return $responsePayload;
|
2020-06-21 21:31:30 +02:00
|
|
|
}
|
2020-08-07 21:47:04 +02:00
|
|
|
$this->set('metaGroup', $this->isAdmin ? 'Administration' : 'Cerebrate');
|
2020-06-21 21:31:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function add()
|
|
|
|
{
|
2020-08-07 21:47:04 +02:00
|
|
|
$this->set('metaGroup', $this->isAdmin ? 'Administration' : 'Cerebrate');
|
|
|
|
$this->CRUD->add([
|
|
|
|
'displayOnSuccess' => 'authkey_display'
|
|
|
|
]);
|
2021-01-14 11:33:51 +01:00
|
|
|
$responsePayload = $this->CRUD->getResponsePayload([
|
|
|
|
'displayOnSuccess' => 'authkey_display'
|
|
|
|
]);
|
2021-01-11 16:28:07 +01:00
|
|
|
if (!empty($responsePayload)) {
|
|
|
|
return $responsePayload;
|
2020-06-21 21:31:30 +02:00
|
|
|
}
|
|
|
|
$this->loadModel('Users');
|
|
|
|
$dropdownData = [
|
|
|
|
'user' => $this->Users->find('list', [
|
|
|
|
'sort' => ['username' => 'asc']
|
|
|
|
])
|
|
|
|
];
|
|
|
|
$this->set(compact('dropdownData'));
|
|
|
|
}
|
|
|
|
}
|