modified 优化Token获取方式

This commit is contained in:
zhaoxiang 2020-10-13 18:17:09 +08:00
parent aa14f1e2c1
commit b47aa8c985
3 changed files with 11 additions and 1 deletions

View File

@ -42,7 +42,7 @@ php think apiadmin:adminRouter
> 第五步:获取管理后台账号密码 > 第五步:获取管理后台账号密码
``` ```
cat application/install/lock.ini cat install/lock.ini
``` ```
## 灵 感 ## 灵 感

View File

@ -30,6 +30,7 @@ class BuildToken extends Base {
$signature = $param['signature']; $signature = $param['signature'];
unset($param['signature']); unset($param['signature']);
unset($param['Access-Token']);
$sign = $this->getAuthToken($appInfo['app_secret'], $param); $sign = $this->getAuthToken($appInfo['app_secret'], $param);
$this->debug($sign); $this->debug($sign);
if ($sign !== $signature) { if ($sign !== $signature) {

View File

@ -50,7 +50,16 @@ class ApiAuth {
} }
} }
$accessToken = $request->header('Access-Token', ''); $accessToken = $request->header('Access-Token', '');
if (!$accessToken) {
if ($apiInfo['method'] == 2) {
$accessToken = $request->get('Access-Token', '');
}
if ($apiInfo['method'] == 1) {
$accessToken = $request->post('Access-Token', '');
}
}
if (!$accessToken) { if (!$accessToken) {
return json([ return json([
'code' => ReturnCode::AUTH_ERROR, 'code' => ReturnCode::AUTH_ERROR,