Browse Source

优化代理商(商户检查)

dev
李可松 4 years ago
parent
commit
41e992957a
  1. 4
      app/Http/Controllers/Controller.php
  2. 4
      app/Http/Middleware/ApiBase.php

4
app/Http/Controllers/Controller.php

@ -17,13 +17,11 @@ class Controller extends BaseController
public function __construct()
{
// Cache::put('wx0e8ebcd9ca9e4b97', 1);
// Cache::put('c4ca4238a0b923820dcc509a6f75849b', 1);
// TODO 登录部分待优化
$auth = request()->header('Authentication');
$appid = request()->header('appid');
//代理商和用户已经在中间件中检查过了,这里不再重复检查,也避免后台出错
//代理商和用户已经在ApiBase和ApiAuth中间件中检查过了,这里不再重复检查,也避免后台出错
if ($auth) {
$this->user_id = Cache::get($auth);
}

4
app/Http/Middleware/ApiBase.php

@ -22,8 +22,8 @@ class ApiBase
}
//检查代理商
$agent_id = Cache::get($appid);
if (empty($agent_id) || $agent_id != Agent::query()->where(['appid' => $appid, 'status' => 1])->value('id')) {
$agent_id = Agent::query()->where(['appid' => $appid, 'status' => 1])->value('id');
if (empty($agent_id)) {
return response()->json([
'code' => -1,
'msg' => '商户不存在或已被禁用',

Loading…
Cancel
Save