AdminBase.php 977 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * Created by PhpStorm
  4. * User:林志杰
  5. * Email:[email protected]
  6. * Motto:纵有疾风起,人生不言弃!
  7. * Time:2020/1/3 23:30
  8. */
  9. namespace app\admin\controller;
  10. use app\BaseController;
  11. use think\exception\HttpResponseException;
  12. class AdminBase extends BaseController
  13. {
  14. public $adminUser = null;
  15. public function initialize()
  16. {
  17. parent::initialize();
  18. // 判断是否登录 判断是否登陆 切换到 中间件Auth中
  19. // if (!$this->isLogin()) {
  20. // return $this->redirect(url('login/index'), 302);
  21. // }
  22. }
  23. /**
  24. * 判断是否登录
  25. * @return bool
  26. */
  27. public function isLogin()
  28. {
  29. $this->adminUser = session(config('admin.session_admin'));
  30. if (empty($this->adminUser)) {
  31. return false;
  32. }
  33. return true;
  34. }
  35. public function redirect(...$args)
  36. {
  37. throw new HttpResponseException(redirect(...$args));
  38. }
  39. }