Function
A wrong email and a wrong password produce the same message, because the
server answers both the same way. On success the learner is sent to
returnPath and the server tree is refreshed, so the header and every
layout render as signed in.
The wait runs from the moment the form is submitted until the navigation
takes the page away — isLeaving covers the gap between the credentials
being accepted and the route changing, so the form never flashes back into
view. Only a refusal returns it, with the learner's typing intact.
The wait does not survive the navigation, and cannot: the destination's
loading.tsx is a Suspense boundary the App Router mounts as soon as the
route suspends, so it replaces this page whatever the navigation is wrapped
in — a transition included. The destination's shell carries the wait from
there, and the two read as one sequence.
Signs a verified learner in with email and password, behind a Turnstile challenge, or with Google.