Skip to content

Commit 3a90d28

Browse files
committed
fix the unauthorized redirect url.
1 parent ea5211d commit 3a90d28

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

packages/Webkul/Admin/src/Http/Controllers/User/SessionController.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,13 @@ public function store(): RedirectResponse
7070
return redirect()->to($availableNextMenu->getUrl());
7171
}
7272

73-
$intendedUrl = redirect()->getIntendedUrl();
73+
$hasAccessToIntendedUrl = $this->canAccessIntendedUrl($menus, redirect()->getIntendedUrl());
7474

75-
$routeName = $this->findIntendedRoute($menus, $intendedUrl);
76-
77-
if (
78-
$routeName
79-
&& ! bouncer()->hasPermission($routeName->getKey())
80-
) {
81-
return redirect()->to($availableNextMenu->getUrl());
75+
if ($hasAccessToIntendedUrl) {
76+
return redirect()->intended(route('admin.dashboard.index'));
8277
}
8378

84-
return redirect()->intended(route('admin.dashboard.index'));
79+
return redirect()->to($availableNextMenu->getUrl());
8580
}
8681

8782
/**
@@ -97,7 +92,7 @@ public function destroy(): RedirectResponse
9792
/**
9893
* Find menu item by URL.
9994
*/
100-
protected function findIntendedRoute(Collection $menus, ?string $url): ?MenuItem
95+
protected function canAccessIntendedUrl(Collection $menus, ?string $url): ?MenuItem
10196
{
10297
if (is_null($url)) {
10398
return null;
@@ -109,7 +104,7 @@ protected function findIntendedRoute(Collection $menus, ?string $url): ?MenuItem
109104
}
110105

111106
if ($menu->haveChildren()) {
112-
$found = $this->findIntendedRoute($menu->getChildren(), $url);
107+
$found = $this->canAccessIntendedUrl($menu->getChildren(), $url);
113108

114109
if ($found) {
115110
return $found;

0 commit comments

Comments
 (0)