【问题标题】:Auth logout in cakephp 3x with plugin ADmad/cakephp-jwt-auth使用插件 ADmad/cakephp-jwt-auth 在 cakephp 3x 中验证注销
【发布时间】:2016-09-10 16:50:36
【问题描述】:

我想销毁令牌,但那不起作用:

$this->Auth->注销();

你能帮帮我吗?谢谢大家

【问题讨论】:

    标签: php cakephp-3.0


    【解决方案1】:
     public function login()
        {
            if ($this->request->is('post')) {
                $user = $this->Auth->identify();
                if ($user) {
                    $this->Auth->setUser($user);
                    return $this->redirect($this->Auth->redirectUrl());
                }
                $this->Flash->error(__('Invalid username or password, try again'));
            }
        }
    
        public function logout()
        {
            return $this->redirect($this->Auth->logout());
        }
    

    【讨论】:

    • 我试过但是登录时返回旧令牌。谢谢
    【解决方案2】:

    Jwt 未存储在服务器上。要注销,您只需删除客户端上的令牌。 如果您想在过期之前使其失效,则必须手动将令牌插入数据库并在每次请求时检查令牌是否失效

    【讨论】:

      猜你喜欢
      • 2016-07-31
      • 2015-02-21
      • 2011-05-09
      • 2017-07-05
      • 2015-06-20
      • 2017-08-10
      • 2016-02-20
      • 1970-01-01
      • 2013-03-25
      相关资源
      最近更新 更多