SuperAuth.php 776B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace App\Http\Middleware;
  3. use Closure;
  4. use App\Common\Api;
  5. class SuperAuth
  6. {
  7. /**
  8. * Handle an incoming request.
  9. *
  10. * @param \Illuminate\Http\Request $request
  11. * @param \Closure $next
  12. * @return mixed
  13. */
  14. public function handle($request, Closure $next)
  15. {
  16. //登录鉴权 session内用户是否存在,存在则通过,不存在则回调到登录界面
  17. $userInfo = $request->session()->get('userInfo');
  18. if(empty($userInfo)){
  19. return redirect('manage');
  20. }
  21. if($userInfo['is_admin'] != 1){
  22. return redirect('https://s1-hn.aghcdn.com/activity/common/page/crowd/errEvir.html?error='.urlencode('无权访问'));
  23. }
  24. return $next($request);
  25. }
  26. }