0
0

Auth.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace app\admin\controller;
  3. use think\Db;
  4. class Auth extends Base
  5. {
  6. public $userId;
  7. public $orgId;
  8. public $rolesId;
  9. protected function initialize()
  10. {
  11. if(!is_login()){
  12. if(request()->isAjax()){
  13. $this->error('未登录,请先登录');
  14. }else{
  15. $this->redirect(url('common/login'));
  16. }
  17. }
  18. $this->userId = is_login();
  19. $this->orgId = cur_org_id();
  20. $user = session('user_auth');
  21. $this->rolesId = !empty($user)&&isset($user['rolesId'])?$user['rolesId']:0;
  22. $this->assign('rolesId',$this->rolesId);
  23. // 检查是否有紧急事件
  24. $info = Db::name('burst_record')
  25. ->where('user_id',$this->userId)
  26. ->where('status',1)
  27. ->where('del',0)
  28. ->find();
  29. if($info){
  30. $this->redirect(url('Bursting/index'));
  31. }
  32. parent::initialize();
  33. }
  34. public function getTableField($table,$where,$field){
  35. $val = Db::name($table)
  36. ->where($where)
  37. ->value($field);
  38. return $val;
  39. }
  40. }