Skip to content

fix: send guests to login when auth middleware refuses a native screen - #666

Merged
simonhamp merged 1 commit into
mainfrom
fix/screen-guard-guest-redirect
Nov 12, 2026
Merged

simonhamp merged 1 commit into
mainfrom
fix/screen-guard-guest-redirect

Conversation

@shanerbaner82

Copy link
Copy Markdown
Contributor

Since #348 (4.7.0), a guest who navigates in-app to a Route::native() screen behind auth lands on start_url instead of the login screen.

ScreenGuard catches the AuthenticationException and calls $e->redirectTo() with no arguments. Since Laravel 11, that method requires the request, so the call throws ArgumentCountError. The guard reports it as a failed guard and falls back to start_url.

This passes the request to redirectTo(). Laravel 10's version takes no argument, and PHP ignores the extra one there.

Adds a test with Laravel's real auth middleware: a guest is sent to /login, the screen never mounts, and nothing is reported. It fails on main and passes with the fix. Full suite: 2442 passed, 4 skipped.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@simonhamp
simonhamp merged commit e2eae7b into main Nov 12, 2026
6 checks passed
@simonhamp
simonhamp deleted the fix/screen-guard-guest-redirect branch November 12, 2026 16:42
gwleuverink added a commit that referenced this pull request Nov 17, 2026
Covers mobile PRs #452, #652, #653, #654, #655, #656, #658, #659, #661, #662, #663, #664, #666, #667, #668, #670, #671, #672, #673, #675, #677 and #678, and the commit on main without a PR: e9e2049 (Bifrost build service in the README). Main 1ad5cf5..5bcd753, 23 commits.

Ported to core on branch sync/mobile-main-2026-11-16 of NativePHP/core, which this merge needs: #658 "Sign the durable native-callback cache copy with the app key" (src/Support/NativeCallbacks.php), #667 (min-scale on Text), #661 (dragEnd handlers through invokeUiInteraction()), #670 (Element::closesOnNavigation() and its registry lookup, read by core's farewell frame), #675 (#[Memo] child components, captureRoots(), the compiled view checks once per frame, and the view creator in CoreServiceProvider), #452 (Transition::SlideToBottom and the transition argument on navigate(), back() and replace()) and #677 (property handlers and InvalidHandlerException). Memo and InvalidHandlerException move to core. Their old names resolve to core's through the alias shim.

Kept on this branch, as main has them: #670's BottomSheet::closesOnNavigation(), #452's transition on TopBarAction, #678's NativeLayout default, and the docblock #670 gave the farewell frame, which now sits on typesClosedInFarewellFrame(). #653 "Authenticate device events posted to /_native/api/events" merged with DispatchEventFromAppController holding both its check and the core marker check from 23300cc. Its new src/Support/NativeEventSignature.php stays in mobile, next to that controller.

Removed again in the merge: CallbackRegistry, Element, ElementRegistry, Text, NativeElementCollector, NativeTagPrecompiler, Transition and NativeCallbacks (main changed them, core has them), Memo and InvalidHandlerException (main added them, core has them), and both cacert.pem copies (main changed them, core ships the bundle). #659 is not ported, as core #21 brings the same file. Main's one line in NativeServiceProvider's view creator is in core's CoreServiceProvider now.

AGENTS.md keeps this branch's shared copy. The AGENTS.md that #658 added to main is not taken in. Where its text goes waits for the owner.

Adapted for the extraction: MemoComponentsTest reads nativeMemoRoots through core's NativeComponent, which declares it private.

Needs NativePHP/core branch sync/mobile-main-2026-11-16 (on #20, which is on #18), and #19 as before.

Tests, all on PHP 8.4.27, with core at a local merge of sync/mobile-main-2026-11-16 and #19 (323952d): mobile on this merge, 2,571 passed, 4 risky, 4 skipped (2,485 before the merge). PHPStan: the same 3 errors in RunsAndroid as before. Mobile main (5bcd753), 2,507 passed, 4 risky, 4 skipped. Desktop test:php, main (a9986fd) 2,253 passed and refactor/desktop-layout (87a60ce) 2,552 passed, the same as against the core of 2026-11-04.
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