Disabled request lifecycle middleware on public routes

Effectively sets no cookies on public pages
This commit is contained in:
Julian Prieber 2023-07-19 18:14:19 +02:00
parent 53d74c7ac8
commit 658617c8bb
3 changed files with 57 additions and 52 deletions

View File

@ -29,13 +29,15 @@ class Kernel extends HttpKernel
* @var array
*/
protected $middlewareGroups = [
'web' => [
'AuthSession' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
// \Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
],
'web' => [
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
@ -43,6 +45,7 @@ class Kernel extends HttpKernel
'throttle:api',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
];
/**

View File

@ -8,6 +8,7 @@ use App\Http\Controllers\Auth\NewPasswordController;
use App\Http\Controllers\Auth\PasswordResetLinkController;
use App\Http\Controllers\Auth\RegisteredUserController;
use App\Http\Controllers\Auth\VerifyEmailController;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;
if (config('advanced-config.register_url') != '') {
@ -28,7 +29,9 @@ if(config('advanced-config.forgot_password_url') != '') {
$forgot_password = "/forgot-password";
}
if(env('ALLOW_REGISTRATION') or $register !== '/register') {
Route::middleware(['web', 'AuthSession'])->group(function () use ($register, $login, $forgot_password) {
if (env('ALLOW_REGISTRATION') || $register !== '/register') {
Route::get($register, [RegisteredUserController::class, 'create'])
->middleware('guest')
->middleware('max.users')
@ -101,4 +104,4 @@ Route::get('/blocked', function () {
return redirect(url('dashboard'));
}
})->name('blocked');
});

View File

@ -96,7 +96,7 @@ Route::get('/vcard/{id?}', [UserController::class, 'vcard'])->name('vcard');
Route::get('/demo-page', [App\Http\Controllers\HomeController::class, 'demo'])->name('demo');
Route::middleware(['auth', 'blocked', 'impersonate'])->group(function () {
Route::middleware(['AuthSession', 'auth', 'blocked', 'impersonate'])->group(function () {
//User route
Route::group([
'middleware' => env('REGISTER_AUTH'),
@ -141,11 +141,10 @@ Route::get('/studio/linkparamform_part/{typeid}/{linkid}', [LinkTypeViewControll
});
}
Route::middleware(['AuthSession', 'auth', 'blocked', 'impersonate'])->group(function () {
//Social login route
Route::get('/social-auth/{provider}/callback', [SocialLoginController::class, 'providerCallback']);
Route::get('/social-auth/{provider}', [SocialLoginController::class, 'redirectToProvider'])->name('social.redirect');
Route::middleware(['auth', 'blocked', 'impersonate'])->group(function () {
//Admin route
Route::group([
'middleware' => 'admin',