Log message #4205088

# At Username Text
# Sep 22nd 2019, 15:06 admad the 2 components are not dependent on each other
# Sep 22nd 2019, 15:03 nucc1 I like the convenience as well, but i want to do the decision making about what to do myself
# Sep 22nd 2019, 15:03 nucc1 I am hoping to use the Authorization comonent as well and assumed they go together
# Sep 22nd 2019, 15:02 admad the component just provides some extra convenience, it's not really necessary for the auth process
# Sep 22nd 2019, 15:02 admad *that's one way
# Sep 22nd 2019, 15:02 admad they one way. Another thing is for what else do you need the component?
# Sep 22nd 2019, 14:58 nucc1 did you mean make it default to allow-all and then just read the results and do what I desire? I can't see how too use it without loading it
# Sep 22nd 2019, 14:52 nucc1 thanks. :)
# Sep 22nd 2019, 13:30 admad *AuthenticationComponent
# Sep 22nd 2019, 13:30 admad nucc1: just dont load the AuthComponent? Then you can just check result and do whatever you want
# Sep 22nd 2019, 12:59 nucc1 when using the Authentication plugin, is it possible to catch and do something else with the UnAuthenticatedException, or do I have to rely on the redirect?
# Sep 22nd 2019, 12:42 noel There are but they don't seem to work for json-api. Thx anyhow.
# Sep 22nd 2019, 12:27 adam282 I am sure there is some built-in Cake routines and response handlers for JSON
# Sep 22nd 2019, 12:26 adam282 Honestly, I have no idea as in the last app I wrote, I had a small subset of functions that required a JSON response and that was CakePHP 2.x so I did it the way you just mentioned.
# Sep 22nd 2019, 12:22 noel @adam282 turning off autorender and setting the layout to false does indeed prevent the template from being required, which is cool. However _serialize doesn't result in any output. Is there a way to interact with crud-json-api's classes so as to build up a json-api response? Obviously I build up an array manually and then json_encode it and send it as a response but that seems like re-inventing the wheel.
# Sep 22nd 2019, 12:18 noel Ok tx I'll try that. I found this works although it seems heavy-handed: ``` public function index() { if ($this->request->is('jsonapi')) { $response = new \Cake\Http\Response; $response = $response->withType('application/json') ->withStringBody(json_encode(['success' => true])); } return $response; } ```
# Sep 22nd 2019, 12:13 adam282 Something like this inside your function inside your Controller: ``` $this->viewBuilder()->setLayout(false); $this->autoRender = false; ```
# Sep 22nd 2019, 12:12 adam282 Yeah, you need to turn off autorender and set the layout to false
# Sep 22nd 2019, 12:09 noel Hi. Working with crud-json-api – is there a way to have a custom response that has nothing to do with table's in the database for a particular Controller? I tried doing `$this->loadComponent('RequestHandler')` and `$this->set('_serialize', ['myVar'])` but it still seems to be asking for the template.
# Sep 22nd 2019, 11:19 admad @val https://github.com/FriendsOfCake/fixturize
# Sep 22nd 2019, 09:34 valerij.bancer Hi, is there an alternative of Fixturize plugin in 3.x? https://github.com/lorenzo/cakephp-fixturize
# Sep 22nd 2019, 07:29 maymeow need adwise I have relations `users -> addresses -> posts` When administrator wants to delete address or user what to do or what are you doing? • Cascading delete ? (so all things related to users and addresses are deleted • Deactivate user address etc ... so all posts are keep in database?
# Sep 21st 2019, 23:19 D-rex How do I disable csrf?
# Sep 21st 2019, 23:18 D-rex Keep getting CSRF token mismatch even after rem,oving the middleware from the route scope
# Sep 21st 2019, 20:55 noel Ok nvm. Got it
# Sep 21st 2019, 20:39 noel Actually I got the PATCH request working now. However I still have the issue with the exception renderer.
# Sep 21st 2019, 18:50 noel So I assume this is because errorException renderer isn't set up for JSON API... but I can't seem to get that set up using the information in the docs. Any help appreciated tx.
# Sep 21st 2019, 18:49 slackebot Crud\Error\Exception\ValidationException ```
# Sep 21st 2019, 18:49 noel So this is the body of my PATCH request: ``` { "data": { "type": "cocktails", "attributes": { "id": "22", "name": "Sex on a beach", "description": "Scratchy but fun" } } } ``` and the headers are: ``` Accept: application/vnd.api+json Content-Type: application/vnd.api+json ``` and the return is a 422 Unprocessable exception showing as HTML with the text: ``` A validation error occurred
# Sep 21st 2019, 18:48 noel It works correctly for GET but the problem is that when I try to update via PostMan using a PATCH request, I'm getting an HTML validation error response instead of a json response. Also the validation error is not specified, it just says "validation error".
# Sep 21st 2019, 18:39 noel Hi guys. Can someone please help me to set up error exception renderer for JSON API? The docs here are apparently out of date: https://crud-json-api.readthedocs.io/en/latest/preface/setup.html, what's shown there doesn't work.
# Sep 21st 2019, 16:53 peppejaripappalardo thx anyway
# Sep 21st 2019, 16:53 peppejaripappalardo np @destinydriven
# Sep 21st 2019, 14:22 destinydriven Sysmo, sorry I can’t be of much help
# Sep 21st 2019, 10:04 peppejaripappalardo thx @destinydriven i saw it, but the error persist
# Sep 21st 2019, 09:24 destinydriven @peppejaripappalardo ^
# Sep 21st 2019, 09:20 destinydriven You have duplicate key ‘duration’
# Sep 21st 2019, 09:18 peppejaripappalardo some hint please? :S
# Sep 21st 2019, 09:18 slackebot ],`
# Sep 21st 2019, 09:18 peppejaripappalardo `'_cake_core_' => [` ` 'className' => RedisEngine::class,` ` 'prefix' => 'myapp_cake_core_',` ` 'path' => CACHE . 'persistent/',` ` 'serialize' => true,` ` 'duration' => '+1 years',` ` 'host' => 'gjnas.serveftp.com',` ` 'password' => '*****',` ` 'database' => 0,` ` 'port' => 6379,` ` 'duration' => '+24 hours',` `
# Sep 21st 2019, 09:18 peppejaripappalardo `Cache engine Cake\Cache\Engine\RedisEngine is not properly configured`