# |
Sep 18th 2019, 20:24 |
ricksaccous |
https://book.cakephp.org/3.0/en/controllers/middleware.html#cross-site-request-forgery-csrf-middleware |
# |
Sep 18th 2019, 20:24 |
ricksaccous |
yeah I'd say so |
# |
Sep 18th 2019, 20:23 |
noel |
So I suppose I should register it only for non API prefixes? |
# |
Sep 18th 2019, 20:22 |
noel |
Like this: ``` Router::scope('/', function (RouteBuilder $routes) { // Register scoped middleware for in scopes. $routes->registerMiddleware('csrf', new CsrfProtectionMiddleware([ 'httpOnly' => true, ])); ``` |
# |
Sep 18th 2019, 20:21 |
noel |
in the routes.php file |
# |
Sep 18th 2019, 20:21 |
noel |
middleware |
# |
Sep 18th 2019, 20:20 |
ricksaccous |
are you enabling it in the first place via routing or middleware? |
# |
Sep 18th 2019, 20:20 |
noel |
Ok tx. Got that... now the CSRF error is back, even though it's disabled in the beforeFilter. |
# |
Sep 18th 2019, 20:20 |
ricksaccous |
use Cake\Event\Event; |
# |
Sep 18th 2019, 20:19 |
ricksaccous |
whatever it is |
# |
Sep 18th 2019, 20:19 |
ricksaccous |
or use |
# |
Sep 18th 2019, 20:19 |
ricksaccous |
you didn't import the class |
# |
Sep 18th 2019, 20:19 |
noel |
Is that just scoping? |
# |
Sep 18th 2019, 20:18 |
noel |
ok tx.. but then I get this error instead: `Declaration of App\Controller\AppController::beforeFilter(App\Controller\Event $event) should be compatible with Cake\Controller\Controller::beforeFilter(Cake\Event\Event $event) ` |
# |
Sep 18th 2019, 20:11 |
ricksaccous |
@noel disable CSRF for your Api |
# |
Sep 18th 2019, 20:11 |
noel |
Hi all. I'm trying to use CrudJsonApi and I'm getting: `Error: CSRF token mismatch.` on a POST using Postman. Any idea how to fix that? |
# |
Sep 18th 2019, 20:03 |
henri.mjr |
Ok, thanks |
# |
Sep 18th 2019, 20:02 |
ricksaccous |
@henri.mjr not really no, you just have to specify a select form control |
# |
Sep 18th 2019, 19:59 |
henri.mjr |
btw form->control show it as "input", its possible to cake understand it as select automatic? |
# |
Sep 18th 2019, 19:59 |
henri.mjr |
`protected function _getTipo($tipo)` ` {` ` $opcoes = ['Branca','Morena','Negra'];` ` return $opcoes;` ` }` |
# |
Sep 18th 2019, 19:58 |
henri.mjr |
Ok.. I got it on entity |
# |
Sep 18th 2019, 19:31 |
henri.mjr |
I'm googling but no luck |
# |
Sep 18th 2019, 19:31 |
henri.mjr |
Do you have an example for cakephp3? |
# |
Sep 18th 2019, 19:26 |
ricksaccous |
up to you, meh |
# |
Sep 18th 2019, 19:26 |
ricksaccous |
you could even make it a virtual property of your entity if you want |
# |
Sep 18th 2019, 19:25 |
ricksaccous |
replacing X with a more descriptive word |
# |
Sep 18th 2019, 19:25 |
ricksaccous |
$entity->getXOptions |
# |
Sep 18th 2019, 19:25 |
ricksaccous |
i always find it kind of neat to do |
# |
Sep 18th 2019, 19:25 |
ricksaccous |
or put it in your table class |
# |
Sep 18th 2019, 19:25 |
ricksaccous |
you can put a get in your entity if you want |
# |
Sep 18th 2019, 19:24 |
henri.mjr |
I need to "hardcode" some options for few selects.. Like "Hair Color", "Body Type". Where is the best place to put it? |
# |
Sep 18th 2019, 19:02 |
LuizMarin |
url workspace on slack? |
# |
Sep 18th 2019, 19:00 |
royalty |
https://app.slack.com/client/T053DPNCM/C053DPNGT |
# |
Sep 18th 2019, 19:00 |
royalty |
you're better off on slack |
# |
Sep 18th 2019, 18:56 |
LuizMarin |
Is there a way to create a user here? |
# |
Sep 18th 2019, 18:45 |
admad |
"I learned to use debug" most important thing to learn as a coder :slightly_smiling_face: |
# |
Sep 18th 2019, 18:44 |
ricksaccous |
awesome ;) |
# |
Sep 18th 2019, 18:43 |
luiz69 |
By the way, I learned to use debug :) |
# |
Sep 18th 2019, 18:43 |
luiz69 |
find the menu) |
# |
Sep 18th 2019, 18:43 |
luiz69 |
Like I said before, I'm learning. I found the problem. Since no fields were changed, it did not save 'last_ip'. I happened to change a piece of content and it worked fine. I didn't know about this cake concept. |
# |
Sep 18th 2019, 18:38 |
luiz69 |
moment please |