ok
Direktori : /home2/selectio/www/3-idiots/app/Http/Middleware/ |
Current File : //home2/selectio/www/3-idiots/app/Http/Middleware/SellerApiAuthMiddleware.php |
<?php namespace App\Http\Middleware; use App\Model\Seller; use Closure; use Illuminate\Http\Request; use function App\CPU\translate; class SellerApiAuthMiddleware { /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next * @return mixed */ public function handle(Request $request, Closure $next) { $token = explode(' ', $request->header('authorization')); if (count($token) > 1 && strlen($token[1]) > 30) { $seller = Seller::where(['auth_token' => $token['1']])->first(); if (isset($seller)) { $request['seller'] = $seller; return $next($request); } } return response()->json([ 'auth-001' => translate('Your existing session token does not authorize you any more') ], 401); } }