From dbcfeabff31ebfac7a695998cfab8438437c815e Mon Sep 17 00:00:00 2001 From: Samuel De Backer Date: Tue, 9 Jan 2018 11:22:12 +0100 Subject: [PATCH] Middleware 'public' set in routes service provider --- src/Providers/RouteServiceProvider.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Providers/RouteServiceProvider.php b/src/Providers/RouteServiceProvider.php index 6f981c9..c8be7cc 100644 --- a/src/Providers/RouteServiceProvider.php +++ b/src/Providers/RouteServiceProvider.php @@ -31,14 +31,16 @@ public function map() * Front office routes */ if ($page = TypiCMS::getPageLinkedToModule('events')) { - $options = $page->private ? ['middleware' => 'auth'] : []; - foreach (locales() as $lang) { - if ($page->translate('status', $lang) && $uri = $page->uri($lang)) { - $router->get($uri, $options + ['uses' => 'PublicController@index'])->name($lang.'::index-events'); - $router->get($uri.'/{slug}', $options + ['uses' => 'PublicController@show'])->name($lang.'::event'); - $router->get($uri.'/{slug}/ics', $options + ['uses' => 'PublicController@ics'])->name($lang.'::event-ics'); + $router->middleware('public')->group(function (Router $router) use ($page) { + $options = $page->private ? ['middleware' => 'auth'] : []; + foreach (locales() as $lang) { + if ($page->translate('status', $lang) && $uri = $page->uri($lang)) { + $router->get($uri, $options + ['uses' => 'PublicController@index'])->name($lang.'::index-events'); + $router->get($uri.'/{slug}', $options + ['uses' => 'PublicController@show'])->name($lang.'::event'); + $router->get($uri.'/{slug}/ics', $options + ['uses' => 'PublicController@ics'])->name($lang.'::event-ics'); + } } - } + }); } /*