jingcai-php/app/Http/Middleware/SellerAuthed.php

29 lines
661 B
PHP
Executable File

<?php
namespace App\Http\Middleware;
use App\Model\Seller\Seller;
use App\Utils\Result;
use Closure;
use Illuminate\Support\Facades\Auth;
class SellerAuthed
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
// auth('seller')->login(Seller::find(1));
if (!auth('seller')->check()) {
return response()->json(Result::failed('Unauthorized', Result::UNAUTHORIZED));
}
return $next($request);
}
}