# |
Dec 22nd 2017, 12:19 |
admad |
did you try moving the parent:: call after the `if` block? |
# |
Dec 22nd 2017, 12:17 |
lilhermit |
if I remove the Crud Component it redirects to `admin:home` |
# |
Dec 22nd 2017, 12:16 |
lilhermit |
yeah it looks like a crud issue |
# |
Dec 22nd 2017, 12:16 |
lilhermit |
yep |
# |
Dec 22nd 2017, 12:16 |
admad |
the execution actually go inside the `if` block? |
# |
Dec 22nd 2017, 12:15 |
lilhermit |
I wonder if its a crud issue?! |
# |
Dec 22nd 2017, 12:15 |
lilhermit |
and yet it still gets to the controller method |
# |
Dec 22nd 2017, 12:15 |
lilhermit |
``` public function beforeFilter(Event $event) { parent::beforeFilter($event); if ($this->authorisedCheck()) { $this->Flash->error('You can not perform this action, please talk to a SuperAdmin'); debug('doing stopPropagation and returning $this->response controller.beforeFilter'); return $this->redirect(['_name' => 'admin:home']); } |
# |
Dec 22nd 2017, 12:14 |
lilhermit |
@admad I am |
# |
Dec 22nd 2017, 12:10 |
admad |
and close your ticket on the authentication plugin repo |
# |
Dec 22nd 2017, 12:09 |
admad |
@lilhermit if you want to prevent an action being executed return response instance from controller's beforeFilter() method |
# |
Dec 22nd 2017, 12:08 |
evg_ |
hello all! |
# |
Dec 22nd 2017, 12:08 |
admad |
stop Crud.beforeFilter or returning false from it won't do anything |
# |
Dec 22nd 2017, 11:44 |
lilhermit |
yeah seems `isAuthorized` is called by the cakephp/authentication source I'll raise it in the github |
# |
Dec 22nd 2017, 11:42 |
lilhermit |
doesn't get there |
# |
Dec 22nd 2017, 11:42 |
lilhermit |
``` public function isAuthorized($user = null) { dd('here'); }``` |
# |
Dec 22nd 2017, 11:42 |
lilhermit |
`isAuthorized` doesn't seem to get called |
# |
Dec 22nd 2017, 11:41 |
hmic |
same concept i guess |
# |
Dec 22nd 2017, 11:41 |
lilhermit |
I'm not using AuthComponent but AuthenticationComponent from cakephp/authentication |
# |
Dec 22nd 2017, 11:40 |
hmic |
you could use a custom authorize object instead of course |
# |
Dec 22nd 2017, 11:39 |
hmic |
https://book.cakephp.org/3.0/en/controllers/components/authentication.html#using-controllerauthorize |
# |
Dec 22nd 2017, 11:38 |
lilhermit |
didn't know about controller authorize?! |
# |
Dec 22nd 2017, 11:38 |
lilhermit |
```/src/Controller/Admin/AdminController.php (line 92) 'doing stopPropagation and returning false in controller Crud.beforeFilter' /src/Controller/Admin/AdminController.php (line 142) 'doing stopPropagation and returning redirect in controller.beforeFilter' /src/Controller/Admin/FixturesController.php (line 175) 'at method'``` |
# |
Dec 22nd 2017, 11:37 |
lilhermit |
yeah it's in before filter too |
# |
Dec 22nd 2017, 11:36 |
hmic |
but use controller authorize instead |
# |
Dec 22nd 2017, 11:36 |
hmic |
additionally, you should try not to put the authorization stuff in a beforefilter |
# |
Dec 22nd 2017, 11:35 |
hmic |
i have not been talking about the crud beforeFilter |
# |
Dec 22nd 2017, 11:34 |
lilhermit |
I know `beforeFilter` is being called as I've put debug in it |
# |
Dec 22nd 2017, 11:34 |
lilhermit |
``` $this->Crud->on('beforeFilter', function(Event $event) { if (!$this->isAuthorised()) { $event->stopPropagation(); return false; } });``` |
# |
Dec 22nd 2017, 11:33 |
lilhermit |
yes |
# |
Dec 22nd 2017, 11:32 |
hmic |
lilhermit: tried returning false from the event? |
# |
Dec 22nd 2017, 11:31 |
lilhermit |
Hi all, does anyone know how to stop Crud from invoking an action? in my beforeFilter (controller) I'm doing `$event->stopPropagation();` and returning a redirect. in Crud.beforeFilter I'm also doing `$event->stopPropagation();` yet the method is getting called |
# |
Dec 22nd 2017, 09:39 |
braeden |
Okay, thanks again! |
# |
Dec 22nd 2017, 09:08 |
ono-t |
god morning! |
# |
Dec 22nd 2017, 08:47 |
neon1024 |
Perhaps a complete table method which does all the find the caching would be easier |
# |
Dec 22nd 2017, 08:47 |
neon1024 |
Plus, you’d want to think about how the caching would work, as a custom finder method quite often just modifies an existing query object |
# |
Dec 22nd 2017, 08:47 |
neon1024 |
@braeden I would suggest perhaps adding an option to the custom finder to control if the method should cache or not |
# |
Dec 22nd 2017, 08:29 |
k4t |
o/ |
# |
Dec 22nd 2017, 08:28 |
neon1024 |
Morning all |
# |
Dec 22nd 2017, 07:30 |
braeden |
thanks |
# |
Dec 22nd 2017, 07:01 |
admad |
@braeden it's fine |