# |
Mar 29th 2019, 13:57 |
liaogz82 |
https://2019.phpconf.asia/ |
# |
Mar 29th 2019, 13:57 |
liaogz82 |
i am tasked to present about cakephp in the next phpconfasia |
# |
Mar 29th 2019, 13:56 |
liaogz82 |
hi another request |
# |
Mar 29th 2019, 13:50 |
liaogz82 |
its default there |
# |
Mar 29th 2019, 13:48 |
ricksaccous |
ohhh ok |
# |
Mar 29th 2019, 13:48 |
liaogz82 |
i have to comment his out |
# |
Mar 29th 2019, 13:48 |
liaogz82 |
my routes.php has this `$routes->applyMiddleware('csrf');` |
# |
Mar 29th 2019, 13:46 |
ricksaccous |
unless you are using your own csrf solution |
# |
Mar 29th 2019, 13:46 |
ricksaccous |
and if you aren't loading it then your api request is not a csrf problem |
# |
Mar 29th 2019, 13:45 |
ricksaccous |
$this->loadComponent('Csrf'); |
# |
Mar 29th 2019, 13:45 |
ricksaccous |
it should be this one |
# |
Mar 29th 2019, 13:45 |
ricksaccous |
wait |
# |
Mar 29th 2019, 13:45 |
ricksaccous |
$this->loadComponent('Security'); |
# |
Mar 29th 2019, 13:45 |
ricksaccous |
what about |
# |
Mar 29th 2019, 13:44 |
liaogz82 |
no it is not there |
# |
Mar 29th 2019, 13:44 |
ricksaccous |
in your code find $this->loadComponent('CSRF'); or whatever it's called |
# |
Mar 29th 2019, 13:44 |
ricksaccous |
;) |
# |
Mar 29th 2019, 13:44 |
ricksaccous |
it is loaded somewhere |
# |
Mar 29th 2019, 13:41 |
liaogz82 |
is there a way to turn it off? |
# |
Mar 29th 2019, 13:41 |
liaogz82 |
no i did not load it in AppController |
# |
Mar 29th 2019, 13:40 |
ricksaccous |
just don't load component if it's api request |
# |
Mar 29th 2019, 13:40 |
ricksaccous |
CSRF is a component isn't it? |
# |
Mar 29th 2019, 13:38 |
liaogz82 |
it seems to be default on |
# |
Mar 29th 2019, 13:37 |
liaogz82 |
how do i do that? |
# |
Mar 29th 2019, 13:35 |
admad |
JSON APIs can't have CSRF problem. Just turn of CSRF check for API urls |
# |
Mar 29th 2019, 13:33 |
liaogz82 |
and I am using API calls with no authentication |
# |
Mar 29th 2019, 13:32 |
liaogz82 |
i have no problems with index but i have a lot of problems with add |
# |
Mar 29th 2019, 13:31 |
liaogz82 |
i been using cake 3.7 and been facing CSRF problems https://github.com/FriendsOfCake/crud-json-api/issues/96 |
# |
Mar 29th 2019, 13:31 |
liaogz82 |
hi guys |
# |
Mar 29th 2019, 13:30 |
admad |
or use Controller::setTableLocator() |
# |
Mar 29th 2019, 13:29 |
admad |
actually can just set `Controller::$_tableLocator` instead |
# |
Mar 29th 2019, 13:28 |
admad |
@val make your own locator class by extending core's `TableLocator`. Then use Controller::modelFactory() to set your locator as for model of type "Table" |
# |
Mar 29th 2019, 13:26 |
joopm |
but i have issue because i have an error the Call to undefined method viewBuilder |
# |
Mar 29th 2019, 13:25 |
joopm |
my component is extends from Component |
# |
Mar 29th 2019, 13:25 |
joopm |
i would like to use he viewbuilder in a component controller |
# |
Mar 29th 2019, 13:25 |
joopm |
hello there |
# |
Mar 29th 2019, 13:21 |
val |
Would it be possible to configure `TableLocator` to change `$config` params passed to `Table` constructor? |
# |
Mar 29th 2019, 13:12 |
admad |
it isn't used under actual query is generated |
# |
Mar 29th 2019, 13:12 |
admad |
you should be able to switch table name even after model is constructed |
# |
Mar 29th 2019, 13:11 |
val |
https://api.cakephp.org/3.6/class-Cake.ORM.Table.html#___construct seems to support `$config['table']` parameter |
# |
Mar 29th 2019, 13:10 |
val |
ok, that might work when the model is already constructed. how would it be possible to do something similar before the model is constructed? I mean to pass the table name to the model constructor. |