123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- /**
- * Token接口
- */
- class Token extends Api
- {
- protected $noNeedLogin = [];
- protected $noNeedRight = '*';
- public function _initialize()
- {
- parent::_initialize();
- }
- /**
- * 检测Token是否过期
- *
- */
- public function check()
- {
- $token = $this->auth->getToken();
- $tokenInfo = \app\common\library\Token::get($token);
- $this->success('', ['token' => $tokenInfo['token'], 'expires_in' => $tokenInfo['expires_in']]);
- }
- /**
- * 刷新Token
- *
- */
- public function refresh()
- {
- $token = $this->auth->getToken();
- $tokenInfo = \app\common\library\Token::get($token);
- $tokenInfo->expiretime = time() + 2592000;
- $tokenInfo->save();
- $this->success('', ['token' => $tokenInfo['token'], 'expires_in' => $tokenInfo['expires_in']]);
- }
- }
|