Skip to content

Commit 278a8dc

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 8bfa904 + 59b0f8a commit 278a8dc

28 files changed

+2030
-919
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ php think apiadmin:adminRouter
4242
> 第五步:获取管理后台账号密码
4343
4444
```
45-
cat application/install/lock.ini
45+
cat install/lock.ini
4646
```
4747

4848
## 灵 感

app/controller/admin/Login.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public function getAccessMenuData(int $uid): array {
139139
}
140140
}
141141

142-
return $returnData;
142+
return array_values($returnData);
143143
}
144144

145145
/**

app/controller/admin/ThirdLogin.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ private function doLogin(string $openid, array $userDetail): Response {
305305
'nickname' => $userDetail['nickname'],
306306
'username' => 'ApiAdmin_qq_' . Strs::randString(8),
307307
'openid' => $openid,
308-
'create_ip' => request()->ip(1),
308+
'create_ip' => sprintf("%u", ip2long($this->request->ip())),
309309
'status' => 1,
310310
'create_time' => time(),
311311
'password' => Tools::userMd5('ApiAdmin')
@@ -336,8 +336,8 @@ private function doLogin(string $openid, array $userDetail): Response {
336336
}
337337
}
338338

339-
$userInfo['access'] = (new Login(App()))->getAccess($userInfo['id']);
340-
$userInfo['menu'] = (new Login(App()))->getAccessMenuData($userInfo['id']);
339+
$userInfo['access'] = (new Login(App()))->getAccess(intval($userInfo['id']));
340+
$userInfo['menu'] = (new Login(App()))->getAccessMenuData(intval($userInfo['id']));
341341

342342
$apiAuth = md5(uniqid() . time());
343343
cache('Login:' . $apiAuth, json_encode($userInfo), config('apiadmin.ONLINE_TIME'));

app/controller/api/BuildToken.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public function getAccessToken() {
3030

3131
$signature = $param['signature'];
3232
unset($param['signature']);
33+
unset($param['Access-Token']);
3334
$sign = $this->getAuthToken($appInfo['app_secret'], $param);
3435
$this->debug($sign);
3536
if ($sign !== $signature) {

app/middleware/ApiAuth.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
use app\model\AdminList;
88
use app\util\ReturnCode;
99
use think\facade\Cache;
10+
use think\Request;
1011

1112
class ApiAuth {
1213

1314
/**
1415
* 获取接口基本配置参数,校验接口Hash是否合法,校验APP_ID是否合法等
15-
* @param $request
16+
* @param Request $request
1617
* @param \Closure $next
1718
* @return mixed|\think\response\Json
1819
* @throws \think\db\exception\DataNotFoundException
@@ -51,6 +52,14 @@ public function handle($request, \Closure $next) {
5152
}
5253

5354
$accessToken = $request->header('Access-Token', '');
55+
if (!$accessToken) {
56+
if ($apiInfo['method'] == 2) {
57+
$accessToken = $request->get('Access-Token', '');
58+
}
59+
if ($apiInfo['method'] == 1) {
60+
$accessToken = $request->post('Access-Token', '');
61+
}
62+
}
5463
if (!$accessToken) {
5564
return json([
5665
'code' => ReturnCode::AUTH_ERROR,

app/middleware/RequestFilter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function handle($request, \Closure $next) {
3535
}
3636

3737
if ($newRule) {
38-
$validate = Validate::make($newRule);
38+
$validate = Validate::rule($newRule);
3939
if (!$validate->check($data)) {
4040
return json(['code' => ReturnCode::PARAM_INVALID, 'msg' => $validate->getError(), 'data' => []]);
4141
}
@@ -50,7 +50,7 @@ public function handle($request, \Closure $next) {
5050
* @return array
5151
* @author zhaoxiang <zhaoxiang051405@gmail.com>
5252
*/
53-
public function buildValidateRule($rule = array()) {
53+
public function buildValidateRule($rule = []) {
5454
$newRule = [];
5555
if ($rule) {
5656
foreach ($rule as $value) {

app/util/Strs.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Strs {
2020
* @return string
2121
*/
2222
public static function uuid(): string {
23-
$charId = md5(uniqid(mt_rand(), true));
23+
$charId = md5(uniqid(strval(mt_rand()), true));
2424
$hyphen = chr(45);
2525
$uuid = chr(123)
2626
. substr($charId, 0, 8) . $hyphen

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"php": ">=7.2.5",
2424
"topthink/framework": "^6.0",
2525
"topthink/think-orm": "^2.0",
26-
"endroid/qrcode": "^3.9"
26+
"topthink/think-migration": "^3.0"
2727
},
2828
"require-dev": {
2929
"symfony/var-dumper": "^4.2",

0 commit comments

Comments
 (0)