Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
575 views
in Technique[技术] by (71.8m points)

初次接触thinkphp 请求接口处的验证token应该放在哪儿

看网上说的 使用前置操作beforeActionList,但是不知道怎么用,所有的api接口 控制器之前都验证token 应该放在哪儿?

namespace appindexcontroller;
class Index extends hinkController
{
    protected $beforeActionList = [
        'checkToken',
    ];
    
    protected function checkToken()
    {
        echo 'checkToken<br/>';
    }
    
    public function index()
    {
        echo '测试';die();
    }
}

上边的index控制器里的beforeActionList 和checkToken()应该放在什么地方 如何在所有控制器调用?给个例子吧 初次接触 没闹明白 用的thinkphp5 多谢


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

可以使用路由中间件


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...