Skip to content

Commit

Permalink
增加 Token 操作类获取数据方法
Browse files Browse the repository at this point in the history
  • Loading branch information
He110te4m committed Feb 18, 2018
1 parent e490811 commit d1c08dd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
20 changes: 20 additions & 0 deletions despote/kernel/Token.php
Expand Up @@ -93,4 +93,24 @@ public function getData($token, $getMethon = true)

return $verify_sign == $sign ? $raw_data : false;
}

public function get($token)
{
if (empty($token)) {
return false;
}
list($header, $data, $sign) = explode(',', $token);

if (empty($header) || empty($data) || empty($sign)) {
return false;
}

$raw_header = json_decode(base64_decode($header), true);
$raw_data = json_decode(base64_decode($data), true);
$raw_sign = $header . ',' . $data;

$verify_sign = base64_encode(Utils::encrypt($raw_sign, $this->secret));

return $verify_sign == $sign ? ['header' => $raw_header, 'data' => $raw_data] : false;
}
}
3 changes: 2 additions & 1 deletion despote/kernel/Tpl.php
Expand Up @@ -20,6 +20,7 @@ class Tpl extends Service
/////////////
// 模板配置 //
////////////

// 模板所在模块名
public $module;
// // 模板内部变量
Expand Down Expand Up @@ -47,7 +48,7 @@ public function init()

// 加载模板引擎配置
$conf = require PATH_CONF . 'tpl.php';
$path = PATH_APP . $this->module . DS . 'view' . DS;
$path = PATH_APP . $this->module . DS . 'tpl' . DS;

// 使用配置文件初始化属性
$this->tplDir = isset($conf['tplDir']) ? $conf['tplDir'] : $path;
Expand Down

0 comments on commit d1c08dd

Please sign in to comment.