From 600e9abeb9f2ae36db7daab5da0eee25eed38d27 Mon Sep 17 00:00:00 2001 From: molong Date: Fri, 10 Nov 2017 11:45:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/controller/Auth.php | 2 +- application/api/controller/User.php | 2 ++ application/common/controller/Api.php | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/application/api/controller/Auth.php b/application/api/controller/Auth.php index 53f44c89..1fe64902 100644 --- a/application/api/controller/Auth.php +++ b/application/api/controller/Auth.php @@ -22,7 +22,7 @@ class Auth extends Api { return $this->data; } - $user = model('User')->feild('uid,username,password,salt')->where('username', $this->request->post('username'))->find(); + $user = model('User')->field('uid,username,password,salt')->where('username', $this->request->post('username'))->find(); if ($user['password'] === md5($this->request->post('password').$user['salt'])) { $this->data['code'] = 1; $user['access_token'] = authcode($user['uid'].'|'.$user['username'].'|'.$user['password'], 'ENCODE'); diff --git a/application/api/controller/User.php b/application/api/controller/User.php index b919ea52..a975cdde 100644 --- a/application/api/controller/User.php +++ b/application/api/controller/User.php @@ -12,6 +12,8 @@ use app\common\controller\Api; class User extends Api { + public $mustToken = true; + public function getuser(){ $this->data['code'] = 1; $this->data['data'] = db('Member')->where('uid', $this->request->param('uid'))->find(); diff --git a/application/common/controller/Api.php b/application/common/controller/Api.php index b845d60c..b4c81ea0 100644 --- a/application/common/controller/Api.php +++ b/application/common/controller/Api.php @@ -12,7 +12,7 @@ namespace app\common\controller; class Api { protected $data = array('code' => 0, 'msg' => '', 'time' => 0, 'data' => ''); - protected $mustToken = false; //是否检查用户行为 + public $mustToken = false; //是否检查用户行为 protected $user = array(); //用户信息 protected $client; //客户端信息 protected $request; @@ -33,8 +33,8 @@ class Api { } if ($this->mustToken) { - if ($this->checkToken($header)) { - $this->data['code'] = '201'; + if (!$this->checkToken($header)) { + $this->data['code'] = '203'; $this->data['data'] = '用户登录信息失效,请重登!'; echo json_encode($this->data);exit(); }