Skip to content

[13.x] allow null to be passed directly to redirectGuestsTo()#59526

Merged
taylorotwell merged 1 commit intolaravel:13.xfrom
timmylindh:feature/redirect-guests-to
Apr 5, 2026
Merged

[13.x] allow null to be passed directly to redirectGuestsTo()#59526
taylorotwell merged 1 commit intolaravel:13.xfrom
timmylindh:feature/redirect-guests-to

Conversation

@timmylindh
Copy link
Copy Markdown
Contributor

Following #59505, which updated the exception handler to respect a null redirect and return a 401 response instead of forcing a redirect to route('login'), the redirectGuestsTo() method still does not accept null in its type signature.

This means API-only apps that want to disable the redirect must use:

$middleware->redirectGuestsTo(fn () => null);

With this change, you can now pass null directly:

$middleware->redirectGuestsTo(null);

Changes

  • Updated redirectGuestsTo() type signature from callable|string to callable|string|null
  • Updated redirectTo() to wrap null in a closure (same as it already does for strings), so it properly propagates through redirectUsing()

Backward Compatibility

This is fully backward compatible. Existing calls with callable or string arguments are unaffected. The only new behavior is that null is now a valid argument.

@taylorotwell taylorotwell merged commit a3d7986 into laravel:13.x Apr 5, 2026
54 checks passed
sumaiazaman added a commit to sumaiazaman/framework that referenced this pull request Apr 5, 2026
PR laravel#59526 added null support to redirectGuestsTo() and the guests
parameter in redirectTo(). The users side was missed — redirectUsersTo()
still only accepts callable|string, and the $users null check in
redirectTo() was not updated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants