Refactor middleware
This commit is contained in:
@@ -21,13 +21,13 @@ class Acceptable
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param string $type
|
||||
* @param string|null $type
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next, $type)
|
||||
public function handle($request, Closure $next, $type = null)
|
||||
{
|
||||
if (!$request->accepts($type)) {
|
||||
if (!$request->accepts($type ?: 'accept:application/json')) {
|
||||
throw new NotAcceptableHttpException();
|
||||
}
|
||||
|
||||
|
||||
@@ -55,10 +55,6 @@ class ApiAuthenticate
|
||||
} catch (ModelNotFoundException $e) {
|
||||
throw new HttpException(401);
|
||||
}
|
||||
} elseif ($request->getUser()) {
|
||||
if ($this->auth->onceBasic() !== null) {
|
||||
throw new HttpException(401);
|
||||
}
|
||||
} else {
|
||||
throw new HttpException(401);
|
||||
}
|
||||
|
||||
@@ -54,10 +54,6 @@ class ApiOptionalAuthenticate
|
||||
} catch (ModelNotFoundException $e) {
|
||||
//
|
||||
}
|
||||
} elseif ($request->getUser()) {
|
||||
if ($this->auth->onceBasic() !== null) {
|
||||
//
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user