AuthDinner.php 677 B

1234567891011121314151617181920212223242526
  1. <?php
  2. namespace app\http\middleware;
  3. use app\hander\HelpHander;
  4. use think\Db;
  5. class AuthDinner
  6. {
  7. public function handle($request, \Closure $next)
  8. {
  9. $token = $request->param('token');
  10. $userId = $request->param('userId');
  11. if(empty($token) || empty($userId)){
  12. HelpHander::error('登录信息已失效',100200);
  13. }
  14. // 检查用户是否被禁用
  15. $user = Db::name('dinner_user')->where('id',$userId)->where('token',$token)->find();
  16. if(!$user || $user['enable'] == 0 || $user['del'] == 1){
  17. HelpHander::error('登录信息已失效',100200);
  18. }
  19. return $next($request);
  20. }
  21. }