Skip to content

[13.x] Allow null in redirectUsersTo() to match redirectGuestsTo()#59546

Open
sumaiazaman wants to merge 2 commits intolaravel:13.xfrom
sumaiazaman:13.x-redirect-users-to-null
Open

[13.x] Allow null in redirectUsersTo() to match redirectGuestsTo()#59546
sumaiazaman wants to merge 2 commits intolaravel:13.xfrom
sumaiazaman:13.x-redirect-users-to-null

Conversation

@sumaiazaman
Copy link
Copy Markdown
Contributor

Summary

PR #59526 added null support to redirectGuestsTo() and the $guests parameter in redirectTo(). The $users side was missed:

  1. redirectUsersTo() still only accepts callable|string — missing null
  2. redirectTo() wraps $guests with is_null() check but not $users

Before

// This works after #59526
->redirectGuestsTo(null)   // ✅

// This doesn't
->redirectUsersTo(null)    // ❌ TypeError

After

->redirectGuestsTo(null)   // ✅
->redirectUsersTo(null)    // ✅

Consistency

Method Accepts null
redirectGuestsTo() ✅ (fixed in #59526)
redirectUsersTo() ❌ → ✅ (this PR)
redirectTo($guests, $users) $guests ✅, $users ❌ → ✅ (this PR)

Changes

  • src/Illuminate/Foundation/Configuration/Middleware.php — Add null to redirectUsersTo() signature and $users null handling in redirectTo()

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.
RedirectIfAuthenticated doesn't handle null redirect like the
unauthenticated handler does (laravel#59505). Just accept null in the
signature for type consistency — null flows through to if($users)
which is false, so RedirectIfAuthenticated is not configured.
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.

1 participant