protected $noNeedLogin = [];
public function _initialize()
{
parent::_initialize();
$post_data['token']=get_token();
if ($this->noNeedLogin){
$controller=request()->action();
if (in_array($controller,$this->noNeedLogin)){
return;
}
}
$token = get_token();
if ($token){
$tokendata=db("user_token")->where(["user_token"=>$token,"end_time"=>[">",time()],"status"=>1])->find();
if ($tokendata){
$this->user_id= $tokendata["user_id"];
}else{
$rs_arr['code']=0;
$rs_arr['msg']="登录已过期,请重新登录";
Response::create($rs_arr, 'json')->send();
exit;
}
}else{
$rs_arr['code']=0;
$rs_arr['msg']="请先登录";
Response::create($rs_arr, 'json')->send();
exit;
}
}
tp5 接口token验证码
最新推荐文章于 2025-02-21 13:22:08 发布