Changeset View
Changeset View
Standalone View
Standalone View
src/app/Http/Middleware/Authenticate.php
<?php | <?php | ||||
namespace App\Http\Middleware; | namespace App\Http\Middleware; | ||||
use Illuminate\Auth\Middleware\Authenticate as Middleware; | use Illuminate\Auth\Middleware\Authenticate as Middleware; | ||||
class Authenticate extends Middleware | class Authenticate extends Middleware | ||||
{ | { | ||||
/** | /** | ||||
* Get the path the user should be redirected to when they are not authenticated. | * Get the path the user should be redirected to when they are not authenticated. | ||||
* | * | ||||
* @param \Illuminate\Http\Request $request | * @param \Illuminate\Http\Request $request | ||||
* | * | ||||
* @return string | * @return string|null | ||||
*/ | */ | ||||
protected function redirectTo($request) | protected function redirectTo($request): ?string | ||||
{ | { | ||||
// We might want to redirect the user to the login route, | // We might want to redirect the user to the login route, | ||||
// however, I think we should not, as we're using API routes only. | // however, I think we should not, as we're using API routes only. | ||||
// Unauthenticated state response is handled in app/Exceptions/Handler.php | // Unauthenticated state response is handled in app/Exceptions/Handler.php | ||||
// if (! $request->expectsJson()) { | // if (! $request->expectsJson()) { | ||||
// return route('login'); | // return route('login'); | ||||
// } | // } | ||||
return null; | |||||
} | } | ||||
} | } |