小编Jos*_*ejo的帖子

错误:cakephp 3.6.10 中的 CSRF 令牌不匹配

我做了一个简单的选择更改。但我有一个问题ang收到以下错误:

Error: [Cake\Http\Exception\InvalidCsrfTokenException] CSRF token mismatch.
Run Code Online (Sandbox Code Playgroud)

这是我在控制器上的功能:

public function municipios() {

$this->viewBuilder()->layout('ajax');
$this->LoadModel('Municipios');
$subregion = $this->request->getData['subregion_id'];


    $municipios = $this->Municipios->find('list',[
        'limit' => 200,

        'conditions' => ['Municipios.subregion_id' => $subregion],
        'contain' => ['Subregiones']

       ]);

    $this->set(compact('municipios'));
    $this->set('_serialize', 'municipios');

}
Run Code Online (Sandbox Code Playgroud)

这是我的 jquery ajax:

$(document).ready(function () {
    $("#subregion-id").bind("change",
    function (event) {
      $.ajax({
    async:true,
    data: $("#subregion-id").serialize(),
    dataType:"html",
    success:
    function (data, textStatus) {
      $("#municipio-id").html(data);
      },
      type:"post", url:"\/lavaderos\/municipios"});
  return false;
      });
  });
Run Code Online (Sandbox Code Playgroud)

我阅读了需要令牌的文档,但我不知道该怎么做。

该代码在 3.5.x 中工作正常,但在 3.6.x 中无效

谢谢

cakephp cakephp-3.0

1
推荐指数
1
解决办法
4078
查看次数

更改消息“您无权访问该位置。” 在cakedc 3.x的cakedc /用户插件中

我正在尝试更改消息

您无权访问该位置。

与cakedc 3.1的cakedc / users插件一起使用,但我找不到方法。

这是我在src / Controller / AppController中的配置:

public function initialize()
    {
        parent::initialize();
        $this->loadComponent('Flash');
        $this->loadComponent('CakeDC/Users.UsersAuth', [
         'authError' => 'Did you really think you are allowed to see that?',
      ]
     );
    }
Run Code Online (Sandbox Code Playgroud)

但是消息仍然是:

您无权访问该位置。

我在做什么错?

谢谢。

authentication cakephp cakedc cakephp-3.0

0
推荐指数
1
解决办法
5448
查看次数

标签 统计

cakephp ×2

cakephp-3.0 ×2

authentication ×1

cakedc ×1