123456789101112131415161718192021222324252627 |
- <?php namespace Manage\Lib;
- use Dever;
- use Dever\Helper\Secure;
- use Dever\Helper\Env;
- class Auth
- {
- protected $login = true;
- protected $uid;
- protected $user;
- public $data = array();
- public function __construct()
- {
- $auth = Env::header('authorization');
- if (!$auth) {
- $info['uid'] = 1;
- //Dever::error('请先登录');
- } else {
- $auth = ltrim($auth, 'Bearer ');
- $info = Secure::checkLogin($auth, 86400*7);
- if (!$info && $this->login) {
- Dever::error('请先登录');
- }
- }
- $this->uid = $info['uid'];
- $this->user = Dever::db('admin')->find($this->uid);
- }
- }
|