isJson() && Helper::isRequestForApiV1($request); // TODO: check this works if ($isApiV1Request) { // Use patched v1 Auth mecanism (without bearer reimplementation) $bearerToken = $request->bearerToken(); $brand = Service::getFromBearerToken($bearerToken)->brand; $request->request->add(['brand_id' => $brand->id]); $response = $next($request); } else { // Use Laravel auth check mecanism $response = \call_user_func_array( [$this, 'parent::' . __FUNCTION__], array_merge([$request, $next], $guards) ); } return $response; } /** * Get the path the user should be redirected to when they are not authenticated. * * @param \Illuminate\Http\Request $request * @return string|null */ protected function redirectTo($request) { if (! $request->expectsJson()) { return route('login'); } } }