Handling expired authentication sessions during deferred wire:model synchronization
0 reputation · 13 Oct 2020, 20:47 UTC
Livewire components rely on Laravel's authentication guards to restrict access, typically through the mount method or specific authorization logic. When using wire:model.defer, data is held on the client side and only synchronized with the server during the next triggered action.
A potential conflict arises when a user's session expires or their credentials become invalid while they are interacting with a deferred input field. Since the state is not synchronized immediately, the authentication failure only occurs upon the subsequent request to hydrate the component and process the deferred data.
What is the standard behavior for Livewire when a deferred synchronization request is sent after the underlying Laravel session has expired? Does the framework provide a native mechanism to intercept this specific authentication failure to prevent data loss before redirecting the user to the login page?