diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index a0921b3f..abdc912f 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -55,7 +55,7 @@ class Kernel extends HttpKernel * @var array */ protected $middlewareAliases = [ - 'auth' => \Illuminate\Auth\Middleware\Authenticate::class, + 'auth' => \App\Http\Middleware\RedirectIfUnauthenticated::class, 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, 'can' => \Illuminate\Auth\Middleware\Authorize::class, diff --git a/app/Http/Middleware/RedirectIfUnauthenticated.php b/app/Http/Middleware/RedirectIfUnauthenticated.php new file mode 100644 index 00000000..bf0b679e --- /dev/null +++ b/app/Http/Middleware/RedirectIfUnauthenticated.php @@ -0,0 +1,20 @@ +route('log-in'); + } + + return $next($request); + } +} diff --git a/routes/web.php b/routes/web.php index b44a6689..18147c8e 100644 --- a/routes/web.php +++ b/routes/web.php @@ -18,8 +18,10 @@ Route::get('/register', [RegisterController::class, 'index'])->name('register'); Route::post('/register', [RegisterController::class, 'store']); -Route::get('/dashboard', DashboardController::class)->name('dashboard'); +Route::middleware('auth')->group(function () { + Route::get('/dashboard', DashboardController::class)->name('dashboard'); -Route::get('/transactions', [TransactionController::class, 'index'])->name('transactions.index'); -Route::get('/transactions/create', [TransactionController::class, 'create'])->name('transactions.create'); -Route::post('/transactions', [TransactionController::class, 'store']); \ No newline at end of file + Route::get('/transactions', [TransactionController::class, 'index'])->name('transactions.index'); + Route::get('/transactions/create', [TransactionController::class, 'create'])->name('transactions.create'); + Route::post('/transactions', [TransactionController::class, 'store']); +});