Browse Source

增加用户检查和代理商检查

dev
李可松 5 years ago
parent
commit
e4a442f560
  1. 14
      app/Http/Controllers/Controller.php

14
app/Http/Controllers/Controller.php

@ -2,6 +2,8 @@
namespace App\Http\Controllers;
use App\Models\Agent;
use App\Models\User;
use Illuminate\Support\Facades\Cache;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
@ -20,8 +22,20 @@ class Controller extends BaseController
// TODO 登录部分待优化
$auth = request()->header('Authentication');
$appid = request()->header('appid');
//检查用户
$this->user_id = Cache::get($auth);
$user = User::query()->firstWhere(['id' => $this->user_id, 'status' => 1]);
if (!$user) {
$this->error('用户不存在或已被禁用');
}
//检查代理商
$this->agent_id = Cache::get($appid);
$agent = Agent::query()->firstWhere(['id' => $this->agent_id, 'status' => 1]);
if (!$agent) {
$this->error('商户不存在或已被禁用');
}
}
protected function success($data = [], $msg = 'success', $code = 0, $status = 200): array

Loading…
Cancel
Save