Log message #4220054

# At Username Text
# Dec 25th 2019, 15:52 ndm How so? Where do you use that?
# Dec 25th 2019, 15:50 challgren @ndm using a different transport would kill DebugTransport
# Dec 25th 2019, 15:48 challgren I give up for today
# Dec 25th 2019, 15:43 ndm Not anymore now though... until the next build that is
# Dec 25th 2019, 15:41 ndm Sure, the change is totally fine, it's just that the docs still say `_csrfToken` ;)
# Dec 25th 2019, 15:39 admad @ndm The reason for the change is getAttribute() is a method of the psr interface while getParam() is cake specific, so static analyzers get sad if you use the latter in middlewares methods as they have the argument typehinted to ServerRequestInterface
# Dec 25th 2019, 15:38 challgren Debug kit is being a POS hmmm may have to try that
# Dec 25th 2019, 15:35 ndm How about using a dummy/mock transport instead?
# Dec 25th 2019, 15:31 challgren Grrrr Im starting to not like Cake 4
# Dec 25th 2019, 15:20 ndm OK then, first of all, .NET MVVM Framworks... their documentations are so absolutely terrible, I could even forgive @admad about the `_csrfToken` mistake :)
# Dec 25th 2019, 15:13 challgren _waits at the end of the line_
# Dec 25th 2019, 15:12 ndm @challgren You'll have to line up in the back, I've got a lot of problems with all sorts of people!
# Dec 25th 2019, 15:09 slackebot <challgren>
# Dec 25th 2019, 15:08 challgren To simulate a failure
# Dec 25th 2019, 15:08 challgren @ndm I have a bunch of grievances!
# Dec 25th 2019, 15:08 admad Why do you even need to mock a mailer?
# Dec 25th 2019, 15:08 challgren Wanted to discuss that issue from a baker perspective, but we can chat later
# Dec 25th 2019, 15:07 admad @challgren am now, on mobile
# Dec 25th 2019, 15:07 ndm Sounds like I need to get my Festivus pole
# Dec 25th 2019, 15:06 admad Merry Christmas bakers :christmas_tree:
# Dec 25th 2019, 15:06 admad @ndm in 3.x it was even a request param not request attribute :)
# Dec 25th 2019, 15:06 challgren Hmmm how do I mock a mailer in cake4. Before it was as simple as `$mock = $this->getMockBuilder('Cake\Mailer\Mailer')->getMock();` now that throws a warning `Static method "getConfig" cannot be invoked on mock object`
# Dec 25th 2019, 14:53 ashesh.social Great working @ndm Thanks !
# Dec 25th 2019, 14:48 ndm *now
# Dec 25th 2019, 14:48 ndm @ashesh.social Sorry, looks like this was renamed in 4.x (but not documented), the attribute name is not just `csrfToken`, with no leading underscore.
# Dec 25th 2019, 14:32 ashesh.social Sorry ??
# Dec 25th 2019, 14:29 challgren admad you around?
# Dec 25th 2019, 14:26 ashesh.social Getting empty while accessing: `$this->request->getAttribute('_csrfToken')`
# Dec 25th 2019, 14:18 ashesh.social Merry Christmas everyone !
# Dec 25th 2019, 14:18 gianmarxgagliardi Merry Xmas all
# Dec 25th 2019, 14:18 challgren Merry xmas all!
# Dec 25th 2019, 14:15 bravo-kernel merry x-mas bakers :christmas_tree:
# Dec 25th 2019, 12:56 ndm That needs to be in your view template and feed your AJAX request. That jQuery stuff there would only work in you'd have a form in your view where a token is present.
# Dec 25th 2019, 12:55 ashesh.social Even I added in the view controller
# Dec 25th 2019, 12:55 slackebot <ashesh.social>
# Dec 25th 2019, 12:54 ashesh.social @ndm hey Oliver, I have added that and still getting the same issue.
# Dec 25th 2019, 12:54 slackebot <ashesh.social>
# Dec 25th 2019, 12:31 ndm You need to add the token to either the request data of your AJAX requests, in a field named `_csrfToken`, or send it in a header named `X-CSRF-Token`. You can obtain the curent token from the request object in your view template: `$this->request->getAttribute('_csrfToken')`
# Dec 25th 2019, 12:27 ashesh.social In cakephp4
# Dec 25th 2019, 12:27 ashesh.social During ajax call
# Dec 25th 2019, 12:27 ashesh.social “Missing CSRF token body in /usr/local/myapp/vendor/cakephp/cakephp/src/Http/Middleware/CsrfProtectionMiddleware.php on line 234”