Created
August 10, 2018 19:24
-
-
Save timeelementopuro/5f87cabac63def6d50a83c551e04d235 to your computer and use it in GitHub Desktop.
app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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' | |
// ] | |
// ]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment