<?php

namespace App\Http\Middleware;

use Closure,Auth,Response;

class AuthenticateApi
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  \Closure $next
     * @param  string|null $guard
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $userAuth = Auth('api')->user();
        if (!$userAuth) {
            return Response::json([
                'status_code' => 401,
                'message' => '请登录',
                'data' => []
            ], 200);
        }

        return $next($request);
    }
}

