Log message #4217509

# At Username Text
# Dec 5th 2019, 16:25 info315 @ndm But AuthComponent is deprecated but you still need it some how :man-shrugging:
# Dec 5th 2019, 16:19 ndm The blog tutorial has been replaced with the CMS tutorial for a reason, but it should work if you follow it completely. If `$this->Auth->allow()` gives you that error, then that means that the auth component hasn't been loaded.
# Dec 5th 2019, 16:17 gianmarxgagliardi @info315 the strangest thing that following the official guide of cakephp you have problems
# Dec 5th 2019, 16:10 info315 @gianmarxgagliardi take a look at this: https://github.com/nook24/blood-pressure This is an example app with Authentication and Authorization you can use to check whats different with your code...
# Dec 5th 2019, 16:07 gianmarxgagliardi :(
# Dec 5th 2019, 15:51 wnasich It seems the Auth component was not initialized and it is not attached to UsersController
# Dec 5th 2019, 15:48 gianmarxgagliardi no one can help me
# Dec 5th 2019, 15:28 info315 Done #13980 :slightly_smiling_face:
# Dec 5th 2019, 15:24 admad yup
# Dec 5th 2019, 15:24 info315 @admad should I open an issue on this?
# Dec 5th 2019, 15:23 admad that check will have to be tweaked
# Dec 5th 2019, 15:21 ndm That's probably what triggers it, even when it's being parsed correctly, the request data will be empty, as it decodes to an empty array, the raw input data however isn't empty, it's `{}`, and that triggers the check in the component, `body = empty, input != empty`. https://github.com/cakephp/cakephp/blob/4.x/src/Controller/Component/RequestHandlerComponent.php#L176-L186
# Dec 5th 2019, 15:17 info315 Angular sends `{}` which should not let the Framework run into any parser errors...
# Dec 5th 2019, 15:16 info315 To be honest - I don't know why it's POST and not GET, there are working several people on this project...
# Dec 5th 2019, 15:14 ndm Well, maybe, kind of... what does `$request->input()` give you? I'm not overly familiar with Angular, but maybe it sends an empty-ish JSON value when no data is present, like `{}`, `''`, `null`, ... That would probably trigger the notice. But again, do you actually have a specific reason to use POST over GET?
# Dec 5th 2019, 15:12 info315 @ndm adding post data solved the Problem, but i guess this is a bug ...
# Dec 5th 2019, 15:05 info315 @ndm This are all the headers the browser sends. This is the javascript: https://github.com/it-novum/openITCOCKPIT/blob/4.x-dev/app/cake4/webroot/js/scripts/controllers/Contactgroups/ContactgroupsAddController.js#L40-L45
# Dec 5th 2019, 15:04 slackebot2 Content-Length: 2 Origin: https://dev-dziegler.oitc.itn Connection: keep-alive Referer: https://dev-dziegler.oitc.itn/ng/ Cookie: CookieAuth=%5...; csrfToken=808e5d68071467a3dca223bfdaa327d503baa9823d324ee4b4219dc31f846f05d87af4407c2fdb85c12f7adf986e90186c327db584f39e4574317da48442bcc2; PHPSESSID=po21fkp3cb3fgek6n8tlpfl791 Pragma: no-cache Cache-Control: no-cache```
# Dec 5th 2019, 15:04 info315 ```Host: dev-dziegler.oitc.itn User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:70.0) Gecko/20100101 Firefox/70.0 Accept: application/json, text/plain, */* Accept-Language: de,en-US;q=0.7,en;q=0.3 Accept-Encoding: gzip, deflate, br Content-Type: application/json;charset=utf-8 X-CSRF-Token: 808e5d68071467a3dca223bfdaa327d503baa9823d324ee4b4219dc31f846f05d87af4407c2fdb85c12f7adf986e90186c327db584f39e4574317da48442bcc2
# Dec 5th 2019, 15:02 ndm Or, if it has no body, why is it a POST request?
# Dec 5th 2019, 15:01 ndm @info315 Why does it have no body? It's not invalid, but possibly a problem for how the request handler components determines deprecated usage. And what headers are you sending?
# Dec 5th 2019, 14:59 slackebot2 src/Model/Table/UsersTable.php // src/Controller/UsersController.php <!-- src/Template/Users/add.ctp -->``` `it gives me an error: Call to a member function allow() on boolean`...`Error in: ROOT\src\Controller\UsersController.php, line 14` as is possible with a copy and paste?
# Dec 5th 2019, 14:59 gianmarxgagliardi I was following this guide for Blog Tutorial - Authentication and Authorization (https://book.cakephp.org/3/en/tutorials-and-examples/blog-auth-example/auth.html) I made a copy of the following files: ```CREATE TABLE users ( id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, username VARCHAR(50), password VARCHAR(255), role VARCHAR(20), created DATETIME DEFAULT NULL, modified DATETIME DEFAULT NULL );``` ```//
# Dec 5th 2019, 14:59 info315 It has no body
# Dec 5th 2019, 14:59 info315 @ndm Thats my POST request: https://dev-dziegler.oitc.itn/contactgroups/loadContacts/61.json?angular=true
# Dec 5th 2019, 14:58 ndm Nobody's going to dig through all that ;) Details about your request would probably be more helpful. What exactly are you sending, data and headers wise?
# Dec 5th 2019, 14:55 info315 It's also on GitHub if this helps: https://github.com/it-novum/openITCOCKPIT/tree/4.x-dev/app/cake4/src
# Dec 5th 2019, 14:49 angelxmoreno :scream:cake 4? @info315 you so fancy!:,)
# Dec 5th 2019, 14:45 slackebot2 //$this->loadComponent('Security'); }```
# Dec 5th 2019, 14:45 info315 In my AppController i still load the RequestHandler like so: ``` public function initialize(): void { parent::initialize(); $this->loadComponent('RequestHandler'); $this->loadComponent('Flash'); // Docs: https://book.cakephp.org/authentication/1/en/index.html $this->loadComponent('Authentication.Authentication', [ 'logoutRedirect' => '/users/login' // Default is false ]);
# Dec 5th 2019, 14:44 slackebot2 RoutingMiddleware($this)) ->add(new AppAuthenticationMiddleware($this, [ //Only redirect .html requests if login is invalid - no json requests 'htmlUnauthenticatedRedirect' => '/users/login' ])) ->add(new AuthorizationMiddleware($this)) ->add(new RequestAuthorizationMiddleware()); return $middlewareQueue; }```
# Dec 5th 2019, 14:44 slackebot2 [CORE/src/Core/functions.php, line 305]``` I use the BodyParserMiddleware in my Application.php: ``` public function middleware($middlewareQueue): MiddlewareQueue { $middlewareQueue ->add(new BodyParserMiddleware()) ->add(ErrorHandlerMiddleware::class) ->add(new AssetMiddleware([ 'cacheTime' => Configure::read('Asset.cacheTime') ])) ->add(new
# Dec 5th 2019, 14:44 info315 With CakePHP 4 i get this error on some on one post request: ```Deprecated (16384): Request's input data parsing feature has been removed from RequestHandler. Use the BodyParserMiddleware in your Application class instead. - /usr/share/openitcockpit/app/cake4/vendor/cakephp/cakephp/src/Event/EventManager.php, line: 311 You can disable deprecation warnings by setting `Error.errorLevel` to `E_ALL and ~E_USER_DEPRECATED` in your config/app.php.
# Dec 5th 2019, 13:38 josbeir no problem :slightly_smiling_face:
# Dec 5th 2019, 13:37 javier.villanueva ok i use matching, i read. thanks!
# Dec 5th 2019, 13:37 javier.villanueva ok thank you
# Dec 5th 2019, 13:37 javier.villanueva Do you say that $conditions not affect to this query?
# Dec 5th 2019, 13:36 josbeir so @javier.villanueva as @neon1024 said: check out https://book.cakephp.org/3/en/orm/retrieving-data-and-resultsets.html#filtering-by-associated-data-via-matching-and-joins
# Dec 5th 2019, 13:36 javier.villanueva sorry xD
# Dec 5th 2019, 13:36 josbeir i needed to read it twice to understand it tho :)
# Dec 5th 2019, 13:35 neon1024 @josbeir Nailing it again! :clap: