Skip to content

Commit ed4016e

Browse files
committed
Moved to param
1 parent f5f0a3e commit ed4016e

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

app/Http/Middleware/LoginRedirect.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@ class LoginRedirect
1010
{
1111
public function handle(Request $request, Closure $next): Response
1212
{
13+
$whitelist = ['roadmap'];
14+
1315
// Store the previous URL in session only if it's not the login route itself and is a valid redirect url
1416
if ($request->is('login') || $request->is('register')) {
1517
// If to check where the request is coming from and set the variable if its a valid route.
16-
if (url()->previous() === route('roadmap')) {
17-
session(['login_redirect' => url()->previous()]);
18-
} elseif (! (url()->previous() === route('login')) && ! (url()->previous() === route('register'))) {
18+
if ($request->has('next') && in_array($request->get('next'), $whitelist)) {
19+
session(['login_redirect' => route($request->get('next'))]);
20+
21+
} elseif (! (strtok(url()->previous(), '?') === route('login')) && ! (strtok(url()->previous(), '?') === route('register'))) {
1922
// If the user moves outside the login page, reset the redirect variable.
2023
session(['login_redirect' => null]);
2124
}

resources/views/layouts/front/nav.blade.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@
1313
{{ __('footer.public-campaigns') }}
1414
</a>
1515
</div>
16-
1716
@if (!isset($minimal) || !$minimal)
1817
<div class="gap-2.5 items-center hidden lg:flex">
1918
@guest()
20-
<a href="{{ route('login') }}" class="btn-login transition-all duration-200">
19+
<a href="{{ route('login', request()->is('roadmap') ? ['next' => 'roadmap'] : []) }}" class="btn-login transition-all duration-200">
2120
{{ __('front.menu.login') }}
2221
</a>
2322
@if (config('auth.register_enabled'))
24-
<a href="{{ route('register') }}" class="btn-register transition-all duration-200">
23+
<a href="{{ route('register', request()->is('roadmap') ? ['next' => 'roadmap'] : []) }}" class="btn-register transition-all duration-200">
2524
{{ __('front.menu.register') }}
2625
</a>
2726
@endif

0 commit comments

Comments
 (0)