Skip to content

Instantly share code, notes, and snippets.

@tisuchi
Last active August 24, 2018 12:17
Show Gist options
  • Select an option

  • Save tisuchi/eb9cad7b6929cfda8712aa1d250fefca to your computer and use it in GitHub Desktop.

Select an option

Save tisuchi/eb9cad7b6929cfda8712aa1d250fefca to your computer and use it in GitHub Desktop.
Laravel Call to undefined method App\Exceptions\Handler::unauthenticated()
<?php
/**
* Convert an authentication exception into an unauthenticated response.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Auth\AuthenticationException $exception
* @return \Illuminate\Http\Response
*/
protected function unauthenticated($request, AuthenticationException $exception)
{
if ($request->expectsJson()) {
return response()->json(['error' => 'Unauthenticated.'], 401);
}
return redirect()->guest('login');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment