added auth scaffolding
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Auth\AuthenticationException;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
@@ -48,4 +49,18 @@ class Handler extends ExceptionHandler
|
||||
{
|
||||
return parent::render($request, $exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect to the login field on failed auth
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param AuthenticationException $exception
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
protected function unauthenticated($request, AuthenticationException $exception)
|
||||
{
|
||||
return $request->expectsJson()
|
||||
? response()->json(['message' => $exception->getMessage()], 401)
|
||||
: redirect()->guest(route('login'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user