解决api接口bug
设置token过期时间为24小时
This commit is contained in:
@@ -8,7 +8,20 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\api;
|
||||
|
||||
use think\App;
|
||||
|
||||
class Base {
|
||||
/**
|
||||
* Request实例
|
||||
* @var \think\Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* 应用实例
|
||||
* @var \think\App
|
||||
*/
|
||||
protected $app;
|
||||
|
||||
public $middleware = [
|
||||
'\app\http\middleware\Validate',
|
||||
@@ -20,20 +33,27 @@ class Base {
|
||||
|
||||
protected $data = ['data' => [], 'code' => 0, 'msg' => ''];
|
||||
|
||||
protected function initialize() {
|
||||
/**
|
||||
* 构造方法
|
||||
* @access public
|
||||
* @param App $app 应用对象
|
||||
*/
|
||||
public function __construct(App $app) {
|
||||
$this->app = $app;
|
||||
$this->request = $this->app->request;
|
||||
}
|
||||
|
||||
protected function success($msg, $url = '') {
|
||||
$this->data['code'] = 1;
|
||||
$this->data['msg'] = $msg;
|
||||
$this->data['url'] = $url ? $url->__toString() : '';
|
||||
$this->data['msg'] = $msg;
|
||||
$this->data['url'] = $url ? $url->__toString() : '';
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
protected function error($msg, $url = '') {
|
||||
$this->data['code'] = 0;
|
||||
$this->data['msg'] = $msg;
|
||||
$this->data['url'] = $url ? $url->__toString() : '';
|
||||
$this->data['msg'] = $msg;
|
||||
$this->data['url'] = $url ? $url->__toString() : '';
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@ class User extends Base {
|
||||
*/
|
||||
public function index(Member $user) {
|
||||
$list = $user->getUserList($this->request);
|
||||
$this->data['code'] = 1;
|
||||
$this->data['data'] = $list;
|
||||
return $this->data;
|
||||
}
|
||||
@@ -37,6 +38,7 @@ class User extends Base {
|
||||
*/
|
||||
public function detail(Member $user) {
|
||||
$info = $user->getUserDetail($this->request);
|
||||
$this->data['code'] = 1;
|
||||
$this->data['data'] = $info;
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ return [
|
||||
'private_key' => env('JWT_PRIVATE_KEY'),
|
||||
'password' => env('JWT_PASSWORD'),
|
||||
//JWT time to live
|
||||
'ttl' => env('JWT_TTL', 60),
|
||||
'ttl' => env('JWT_TTL', 86400),
|
||||
//Refresh time to live
|
||||
'refresh_ttl' => env('JWT_REFRESH_TTL', 20160),
|
||||
//JWT hashing algorithm
|
||||
|
||||
Reference in New Issue
Block a user