pianello-api/app/Http/Middleware/LoggedIn.php
Ale Gallo b91cf0cbde Committing laravel + api (part 1)
committing part of the laravel system with templating files and api implementation.
2023-11-10 15:54:41 +01:00

24 lines
519 B
PHP

<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
class LoggedIn
{
/**
* Redirect user if they are authenticated.
*/
public function handle(Request $request, Closure $next): Response|JsonResponse|RedirectResponse
{
if (!is_null(request()->user())) {
return redirect('/');
} else {
return $next($request);
}
}
}