Skip to content

Commit 315031b

Browse files
jasonvargaclaude
andcommitted
Consume login.redirect session key in 2FA setup redirect
Pulls the value instead of getting it, and caches the result in __invoke so the early-return and the Inertia prop share the same resolved URL. Prevents a stale redirect from lingering in the session after the setup flow completes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 9c8cc3a commit 315031b

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/Http/Controllers/TwoFactorSetupController.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@ public function __construct(Request $request)
1919
public function __invoke(Request $request)
2020
{
2121
$user = User::fromUser($request->user());
22+
$redirect = $this->redirectPath();
2223

2324
if ($user->hasEnabledTwoFactorAuthentication()) {
24-
return redirect($this->redirectPath());
25+
return redirect($redirect);
2526
}
2627

2728
return Inertia::render('auth/two-factor/Setup', [
2829
'routes' => $this->routes($user),
29-
'redirect' => $this->redirectPath(),
30+
'redirect' => $redirect,
3031
]);
3132
}
3233

@@ -38,7 +39,7 @@ protected function redirectPath()
3839
}
3940
}
4041

41-
if ($redirect = session('login.redirect')) {
42+
if ($redirect = session()->pull('login.redirect')) {
4243
if (! URL::isExternalToApplication($redirect)) {
4344
return $redirect;
4445
}

0 commit comments

Comments
 (0)