12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use fast\Random;
- class Token extends Api
- {
- protected $noNeedLogin = [];
- protected $noNeedRight = '*';
- public function __construct(){
- $this->error('投票活动结束了');
- }
-
-
- public function check()
- {
- $token = $this->auth->getToken();
- $tokenInfo = \app\common\library\Token::get($token);
- $this->success('', ['token' => $tokenInfo['token'], 'expires_in' => $tokenInfo['expires_in']]);
- }
-
- public function refresh()
- {
-
- $token = $this->auth->getToken();
- \app\common\library\Token::delete($token);
-
- $token = Random::uuid();
- \app\common\library\Token::set($token, $this->auth->id, 2592000);
- $tokenInfo = \app\common\library\Token::get($token);
- $this->success('', ['token' => $tokenInfo['token'], 'expires_in' => $tokenInfo['expires_in']]);
- }
- }
|