You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.0 KiB
42 lines
1.0 KiB
<?php
|
|
|
|
namespace App\Http\Controllers\Appapi\V1;
|
|
|
|
use App\Exceptions\ApiException;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\User;
|
|
use App\Traits\ApiResponse;
|
|
use App\Traits\FileTools;
|
|
use App\Traits\RedisTool;
|
|
use App\Traits\Tools;
|
|
|
|
class ApiController extends Controller
|
|
{
|
|
use FileTools, Tools, RedisTool, ApiResponse;
|
|
|
|
// public function __construct()
|
|
// {
|
|
// $this->middleware(function ($request, $next) {
|
|
// $this->request = $request;
|
|
//
|
|
// if (auth('api')->check()) {
|
|
// $this->user = $this->current_user();
|
|
// }
|
|
//
|
|
// return $next($request);
|
|
// });
|
|
// }
|
|
|
|
public function current_user()
|
|
{
|
|
$user = auth('api')->user();
|
|
if (blank($user)) {
|
|
return null;
|
|
} else {
|
|
if ($user->status == User::user_status_freeze) {
|
|
throw new ApiException('账号被冻结,请联系客服');
|
|
}
|
|
return $user;
|
|
}
|
|
}
|
|
}
|
|
|