Log message #4192993

# At Username Text
# Jul 12th 2019, 13:58 ricksaccous @jeremy.payne are you doing a multi-site set up with subdomains? just curious
# Jul 12th 2019, 13:56 neon1024 Then you can bind it once globally, and then attach the components where you need them in one neat place
# Jul 12th 2019, 13:55 neon1024 @jeremy.payne I’d look at using a listener
# Jul 12th 2019, 13:54 ricksaccous $this->getController->loadComponent();
# Jul 12th 2019, 13:54 ricksaccous i just load them in the initialize of the main component they all load
# Jul 12th 2019, 13:51 jeremy.payne Yeah that's basically what I'm doing with my `Tenant` facade
# Jul 12th 2019, 13:49 ricksaccous that's generally what i end up doing, not sure how evil it is or isn't but it seems to be working for me
# Jul 12th 2019, 13:49 ricksaccous lol
# Jul 12th 2019, 13:49 ricksaccous you could create a component that loads other components based on criteria and have everything load that component
# Jul 12th 2019, 13:47 jeremy.payne Still towing around with my multi-tenant setup, what's the best way to handle components? I was going to have the `public $components = []` array in my controllers be hooked up to a Tenant helper class that will inject the correct `'ComponentName` => ['className' => Tenant::class('LayoutsComponent')]` but it feels a bit clunky.
# Jul 12th 2019, 13:38 ricksaccous provided in the plugin
# Jul 12th 2019, 13:38 ricksaccous just keep in mind if you go the route i suggested you pretty much lose the functionality of the AuthorizationComponent
# Jul 12th 2019, 13:35 ricksaccous i suppose if you wanted you could also just use policies and have that logic permeate throughout each policy, but i dunno
# Jul 12th 2019, 13:35 ricksaccous or that could be one way to go about it anyway
# Jul 12th 2019, 13:35 ricksaccous and do your acl logic in there
# Jul 12th 2019, 13:35 ricksaccous @igreat I think you have to use this: https://book.cakephp.org/authorization/1.1/en/request-authorization-middleware.html
# Jul 12th 2019, 12:17 igreat https://app.test:8890/api/devices.json
# Jul 12th 2019, 12:17 igreat Use the prefix
# Jul 12th 2019, 12:11 noel @igreat POST still gives CSRF error on both `https://mnr-be:8890/devices.json` and `https://mnr-be:8890/devices/add.json`
# Jul 12th 2019, 12:10 igreat Also check the POST for same request url
# Jul 12th 2019, 12:09 igreat Good
# Jul 12th 2019, 12:09 noel @igreat ok that works for the GET now with the router prefix
# Jul 12th 2019, 12:07 igreat So try this request with GET https://app.test:8890/api/devices.json
# Jul 12th 2019, 12:04 noel And sending a `POST` still complains about the missing CSRF cookie.
# Jul 12th 2019, 12:01 noel @igreat looks like it requires a different folder structure (and adjusted namespace) for DevicesController and templates when using the `api` prefix. I've done this but now I'm getting: `Error: A route matching "array ( 'action' => 'add', 'prefix' => 'api', 'plugin' => NULL, 'controller' => 'Devices', '_ext' => NULL, )" could not be found.`
# Jul 12th 2019, 12:00 noel @admad cool tx. Trying to disable CSRF protection and failing... all the above are attempts at this.
# Jul 12th 2019, 11:57 admad stateless APIs don't need CSRF protection
# Jul 12th 2019, 11:53 noel `https://app.test:8890/api/devices/index.json`
# Jul 12th 2019, 11:53 igreat What is your request like @noel?
# Jul 12th 2019, 11:50 noel I've tried the routing prefix now but I still get the `Error: ApiController could not be found.` message.
# Jul 12th 2019, 11:49 noel I'm also confused because it sounded like your initial suggestion was to disable CSRF, which as I understand it is a controller event, but then you were talking about applying that as router middleware.
# Jul 12th 2019, 11:49 igreat If you are not accessing a resource route or if you did not make `DevicesController` a resource route that error could occur
# Jul 12th 2019, 11:47 igreat But this should give a fix or a direction to what I suggest http://www.bravo-kernel.com/2015/04/how-to-prefix-route-a-cakephp-3-rest-api/
# Jul 12th 2019, 11:46 noel Also I don't understand why we would want an ApiController – since the actions are controlled by the Devices controller. I would have expected that the routing should direct to this controller for the `/api/devices/` route.
# Jul 12th 2019, 11:46 igreat At the time of making the tutorial, I think middleware has not implemented the it is now, hence that part was not included
# Jul 12th 2019, 11:43 igreat Let me see
# Jul 12th 2019, 11:42 igreat Ok
# Jul 12th 2019, 11:34 noel @igreat no I don't have an ApiController. I'm following this tutorial: http://www.bravo-kernel.com/2015/04/how-to-build-a-cakephp-3-rest-api-in-minutes/ but it doesn't seem to work – they don't mention CORS issues, nor do they mention adding an `api` route nor ApiController.
# Jul 12th 2019, 11:33 igreat @noel but you have ApiController?
# Jul 12th 2019, 11:32 igreat You should see that somewhere around line 50 and 58 of your routes.php file
# Jul 12th 2019, 11:28 noel @igreat oh. Ok but when I do that it says: "ApiController could not be found"