Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Controller\Api\V1;
- use Cake\Controller\Controller;
- class AppController extends Controller
- {
- // public $components = [
- // 'Acl' => [
- // 'className' => 'Acl.Acl'
- // ]
- // ];
- public function initialize()
- {
- parent::initialize();
- $this->loadComponent('RequestHandler');
- $this->loadComponent('Flash');
- $this->loadComponent('Crud.Crud', [
- 'actions' => [
- 'Crud.Index',
- 'Crud.View',
- 'Crud.Add',
- 'Crud.Edit',
- 'Crud.Delete'
- ],
- 'listeners' => [
- // 'Crud.Api',
- 'Crud.ApiPagination',
- 'Crud.ApiQueryLog',
- 'Crud.Search',
- ]
- ]);
- if ($this->request->getParam('controller') == 'Users') {
- $this->Crud->addListener('Crud.Api');
- } else {
- $this->Crud->addListener('Crud.JsonApi');
- }
- $this->loadComponent('Auth', [
- 'storage' => 'Memory',
- 'authenticate' => [
- 'Form' => [
- 'scope' => ['Users.active' => 1]
- ],
- 'ADmad/JwtAuth.Jwt' => [
- 'parameter' => 'token',
- 'userModel' => 'Users',
- //'scope' => ['Users.active' => 1],
- 'fields' => [
- 'username' => 'id'
- ],
- 'queryDatasource' => true
- ]
- ],
- 'unauthorizedRedirect' => false,
- 'checkAuthIn' => 'Controller.initialize'
- ]);
- // $this->loadComponent('Auth', [
- // 'authorize' => [
- // 'Acl.Actions' => ['actionPath' => 'controllers/']
- // ],
- // 'loginAction' => [
- // 'plugin' => false,
- // 'controller' => 'Users',
- // 'action' => 'login'
- // ],
- // 'loginRedirect' => [
- // 'plugin' => false,
- // 'controller' => 'Customers',
- // 'action' => 'index'
- // ],
- // 'logoutRedirect' => [
- // 'plugin' => false,
- // 'controller' => 'Users',
- // 'action' => 'login'
- // ],
- // 'unauthorizedRedirect' => [
- // 'controller' => 'Users',
- // 'action' => 'login',
- // 'prefix' => false
- // ],
- // 'authError' => 'You are not authorized to access that location.',
- // 'flash' => [
- // 'element' => 'error'
- // ]
- // ]);
- }
- }
Add Comment
Please, Sign In to add comment