Commit a6a17bcf authored by hujun's avatar hujun

jwt

parent 6e9e480a
......@@ -66,7 +66,8 @@ class Member extends Basic
* @return type
*/
public function logout() {
$id = $this->params['id'];
$id = $this->userId ? $this->userId : $this->params['id'];
$data['status'] = 101;
$data['data'] = '';
$data['msg'] = '';
......
......@@ -32,7 +32,7 @@ class Basic extends Controller
* @var int userId
*/
protected $userId;
protected $user_nick;
protected $phone;
protected $timeStamp_;
......@@ -63,15 +63,16 @@ class Basic extends Controller
}
/* $jwt = new \Firebase\JWT\JWT();
/* $jwt = new \Firebase\JWT\JWT();
$this->authToken = $this->params['AuthToken'];
$result = $jwt->decode($this->authToken, config('jwt_key'), array( 'HS256' )); //解码token
$this->userId = $result['data']["userId"];
$this->phone = $result['data']["phone"];
$this->timeStamp_ = $result["timeStamp_"];
$this->authToken = $this->params['AuthToken'];
$result = $jwt->decode($this->authToken, config('jwt_key'), array( 'HS256' )); //解码token
$this->userId = $result->data->id;
$this->phone = $result->data->phone;
$this->phone = $result->data->user_nick;
$this->timeStamp_ = $result->timeStamp_;
$this->verifyTime();*/
$this->verifyTime(); */
}
......
......@@ -18,8 +18,10 @@ class JwtUntils {
* @return boolean
*/
public function createToken($data){
if ($data) {
$result = \Firebase\JWT\JWT::encode($data, config('jwt_key'));
if ($data) {
$jwt_data['data'] = $data;
$jwt_data['timeStamp_'] = time();
$result = \Firebase\JWT\JWT::encode($jwt_data, config('jwt_key'));
Session::set('authToken', $result);
} else {
$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