Commit a6a17bcf authored by hujun's avatar hujun

jwt

parent 6e9e480a
...@@ -66,7 +66,8 @@ class Member extends Basic ...@@ -66,7 +66,8 @@ class Member extends Basic
* @return type * @return type
*/ */
public function logout() { public function logout() {
$id = $this->params['id']; $id = $this->userId ? $this->userId : $this->params['id'];
$data['status'] = 101; $data['status'] = 101;
$data['data'] = ''; $data['data'] = '';
$data['msg'] = ''; $data['msg'] = '';
......
...@@ -32,7 +32,7 @@ class Basic extends Controller ...@@ -32,7 +32,7 @@ class Basic extends Controller
* @var int userId * @var int userId
*/ */
protected $userId; protected $userId;
protected $user_nick;
protected $phone; protected $phone;
protected $timeStamp_; protected $timeStamp_;
...@@ -63,15 +63,16 @@ class Basic extends Controller ...@@ -63,15 +63,16 @@ class Basic extends Controller
} }
/* $jwt = new \Firebase\JWT\JWT(); /* $jwt = new \Firebase\JWT\JWT();
$this->authToken = $this->params['AuthToken']; $this->authToken = $this->params['AuthToken'];
$result = $jwt->decode($this->authToken, config('jwt_key'), array( 'HS256' )); //解码token $result = $jwt->decode($this->authToken, config('jwt_key'), array( 'HS256' )); //解码token
$this->userId = $result['data']["userId"]; $this->userId = $result->data->id;
$this->phone = $result['data']["phone"]; $this->phone = $result->data->phone;
$this->timeStamp_ = $result["timeStamp_"]; $this->phone = $result->data->user_nick;
$this->timeStamp_ = $result->timeStamp_;
$this->verifyTime();*/ $this->verifyTime(); */
} }
......
...@@ -18,8 +18,10 @@ class JwtUntils { ...@@ -18,8 +18,10 @@ class JwtUntils {
* @return boolean * @return boolean
*/ */
public function createToken($data){ public function createToken($data){
if ($data) { if ($data) {
$result = \Firebase\JWT\JWT::encode($data, config('jwt_key')); $jwt_data['data'] = $data;
$jwt_data['timeStamp_'] = time();
$result = \Firebase\JWT\JWT::encode($jwt_data, config('jwt_key'));
Session::set('authToken', $result); Session::set('authToken', $result);
} else { } else {
$result = false; $result = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment