Skip to content

Commit

Permalink
Code refactor
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Poyigi <[email protected]>
  • Loading branch information
sampoyigi committed May 19, 2024
1 parent b12a2bf commit f7c6f61
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Http/Middleware/CheckLocation.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,16 @@ public function handle(Request $request, Closure $next)
$request->route()->setParameter('location', $location->permalink_slug);
}

if ($location && $request->route()->parameter('location') !== $location?->permalink_slug) {
if (Igniter::runningInAdmin() || !$location) {
return $next($request);
}

$locationParam = $request->route()->parameter('location');
if ($locationParam && $locationParam !== $location->permalink_slug) {
return redirect()->to(page_url('home'));
}

if ((!$location?->isEnabled() && !AdminAuth::getUser()?->hasPermission('Admin.Locations'))) {
if (!$location->isEnabled() && !AdminAuth::getUser()?->hasPermission('Admin.Locations')) {
flash()->error(lang('igniter.local::default.alert_location_required'));

return redirect()->to(page_url('home'));
Expand Down

0 comments on commit f7c6f61

Please sign in to comment.