Skip to content

Commit

Permalink
match inertia scaffolding with livewire in regards to authenticate se…
Browse files Browse the repository at this point in the history
…ssion (#1003)
  • Loading branch information
taylorotwell authored Mar 16, 2022
1 parent de8020c commit 09130d4
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 93 deletions.
6 changes: 5 additions & 1 deletion routes/inertia.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
? 'auth:'.config('jetstream.guard')
: 'auth';

Route::group(['middleware' => [$authMiddleware, 'verified']], function () {
$authSessionMiddleware = config('jetstream.authenticate_session', false)
? config('jetstream.authenticate_session')
: null;

Route::group(['middleware' => array_values(array_filter([$authMiddleware, $authSessionMiddleware, 'verified']))], function () {
// User & Profile...
Route::get('/user/profile', [UserProfileController::class, 'show'])
->name('profile.show');
Expand Down
18 changes: 10 additions & 8 deletions src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ public function handle()
{
// Publish...
$this->callSilent('vendor:publish', ['--tag' => 'jetstream-config', '--force' => true]);

if ($this->argument('stack') === 'livewire') {
copy(__DIR__.'/../../stubs/livewire/config/jetstream.php', config_path('jetstream.php'));
}

$this->callSilent('vendor:publish', ['--tag' => 'jetstream-migrations', '--force' => true]);

$this->callSilent('vendor:publish', ['--tag' => 'fortify-config', '--force' => true]);
Expand Down Expand Up @@ -347,13 +342,20 @@ protected function installInertiaStack()

$this->installServiceProviderAfter('FortifyServiceProvider', 'JetstreamServiceProvider');

// AuthenticateSession Middleware...
// Remove AuthenticateSession Middleware...
$this->replaceInFile(
'// \Illuminate\Session\Middleware\AuthenticateSession::class',
'\Laravel\Jetstream\Http\Middleware\AuthenticateSession::class',
PHP_EOL.' // \Illuminate\Session\Middleware\AuthenticateSession::class,',
'',
app_path('Http/Kernel.php')
);

// AuthenticateSession Middleware...
// $this->replaceInFile(
// '// \Illuminate\Session\Middleware\AuthenticateSession::class',
// '\Laravel\Jetstream\Http\Middleware\AuthenticateSession::class',
// app_path('Http/Kernel.php')
// );

// Middleware...
(new Process([$this->phpBinary(), 'artisan', 'inertia:middleware', 'HandleInertiaRequests', '--force'], base_path()))
->setTimeout(null)
Expand Down
2 changes: 2 additions & 0 deletions stubs/config/jetstream.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

'middleware' => ['web'],

'authenticate_session' => AuthenticateSession::class,

/*
|--------------------------------------------------------------------------
| Jetstream Guard
Expand Down
12 changes: 9 additions & 3 deletions stubs/inertia/routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
]);
});

Route::middleware(['auth:sanctum', 'verified'])->get('/dashboard', function () {
return Inertia::render('Dashboard');
})->name('dashboard');
Route::middleware([
'auth:sanctum',
config('jetstream.authenticate_session'),
'verified',
])->group(function () {
Route::get('/dashboard', function () {
return Inertia::render('Dashboard');
})->name('dashboard');
});
81 changes: 0 additions & 81 deletions stubs/livewire/config/jetstream.php

This file was deleted.

0 comments on commit 09130d4

Please sign in to comment.