Guest User

Untitled

a guest
Aug 10th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. <?php
  2. namespace App\Controller\Api\V1;
  3. use Cake\Controller\Controller;
  4. class AppController extends Controller
  5. {
  6. // public $components = [
  7. // 'Acl' => [
  8. // 'className' => 'Acl.Acl'
  9. // ]
  10. // ];
  11.  
  12. public function initialize()
  13. {
  14. parent::initialize();
  15. $this->loadComponent('RequestHandler');
  16. $this->loadComponent('Flash');
  17. $this->loadComponent('Crud.Crud', [
  18. 'actions' => [
  19. 'Crud.Index',
  20. 'Crud.View',
  21. 'Crud.Add',
  22. 'Crud.Edit',
  23. 'Crud.Delete'
  24. ],
  25. 'listeners' => [
  26. // 'Crud.Api',
  27. 'Crud.ApiPagination',
  28. 'Crud.ApiQueryLog',
  29. 'Crud.Search',
  30. ]
  31. ]);
  32.  
  33.  
  34. if ($this->request->getParam('controller') == 'Users') {
  35. $this->Crud->addListener('Crud.Api');
  36. } else {
  37. $this->Crud->addListener('Crud.JsonApi');
  38. }
  39.  
  40. $this->loadComponent('Auth', [
  41. 'storage' => 'Memory',
  42. 'authenticate' => [
  43. 'Form' => [
  44. 'scope' => ['Users.active' => 1]
  45. ],
  46. 'ADmad/JwtAuth.Jwt' => [
  47. 'parameter' => 'token',
  48. 'userModel' => 'Users',
  49. //'scope' => ['Users.active' => 1],
  50. 'fields' => [
  51. 'username' => 'id'
  52. ],
  53. 'queryDatasource' => true
  54. ]
  55. ],
  56. 'unauthorizedRedirect' => false,
  57. 'checkAuthIn' => 'Controller.initialize'
  58. ]);
  59.  
  60.  
  61. // $this->loadComponent('Auth', [
  62. // 'authorize' => [
  63. // 'Acl.Actions' => ['actionPath' => 'controllers/']
  64. // ],
  65. // 'loginAction' => [
  66. // 'plugin' => false,
  67. // 'controller' => 'Users',
  68. // 'action' => 'login'
  69. // ],
  70. // 'loginRedirect' => [
  71. // 'plugin' => false,
  72. // 'controller' => 'Customers',
  73. // 'action' => 'index'
  74. // ],
  75. // 'logoutRedirect' => [
  76. // 'plugin' => false,
  77. // 'controller' => 'Users',
  78. // 'action' => 'login'
  79. // ],
  80. // 'unauthorizedRedirect' => [
  81. // 'controller' => 'Users',
  82. // 'action' => 'login',
  83. // 'prefix' => false
  84. // ],
  85. // 'authError' => 'You are not authorized to access that location.',
  86. // 'flash' => [
  87. // 'element' => 'error'
  88. // ]
  89. // ]);
  90. }
  91. }
Add Comment
Please, Sign In to add comment