skip to content

In a second-hand marketplace mobile app, where does a signed-out user's checkout link land, and how does the app resume checkout after sign-in?

level: middleimportance: must knowfreq 46%

answer

  1. the gate lives in navigation
  2. park the target, not the screen
  3. survives leaving the app
  4. re-check, then replace sign-in
  5. cancel leaves them on the listing

basics

~20 s

The link lands on the public listing with sign-in over it, while the full checkout stack is kept as a pending destination. After sign-in the app re-checks it and replaces sign-in with checkout; on cancel the user stays on the listing.

solid answer

~50 s

The gate belongs in the navigation layer, as a property of the route (`checkout` needs a session), not inside the checkout screen. The resolver builds the target stack `[browse, listing(123), checkout(123)]`; the gate finds no session, so it installs `[browse, listing(123)]`, presents sign-in as a conditional flow, and records the **pending destination**: the serialised target, used once, with an expiry. Sign-in may leave the app for a browser or an emailed link, and the OS may kill the process meanwhile, so the pending destination goes to small persisted storage, not only memory. On success, re-validate it (still for sale? is this user the seller?) and replace the sign-in flow with checkout, so back leads to the listing rather than to sign-in. On cancel, clear it; the user is already on the listing. Never just *go home after sign-in*.

code

pseudocode · 13 lines
pseudocode
function open(targetStack):
  if needsSession(top(targetStack)) and not session.active:
    pendingStore.save(targetStack, expiresIn = 30 minutes)
    navigator.replaceStack(publicPart(targetStack))   // [browse, listing]
    navigator.present(signIn)
    return
  navigator.replaceStack(targetStack)

function onSignInFinished(success):
  pending = pendingStore.take()                      // read and clear
  navigator.dismiss(signIn)
  if success and pending != null and stillValid(pending):
    navigator.replaceStack(pending)                  // sign-in leaves no trace

go deeper

for a junior

Remember the outcome the user expects: after signing in they reach the checkout they tapped, and sign-in is not left behind in the back stack.

for a middle

Explain the pending destination: what it holds, why it is a single slot used once with an expiry, and why it must outlive the app being killed during sign-in.

for a senior

Show the edge handling: re-validating a sold listing or a seller account, cancel leaving the user on the public listing, and a gate that fires before any screen renders.

for a principal

Argue for one gate owned by the navigation layer as a team rule, so every new gated feature inherits correct resume behaviour without writing its own redirect.

## Where the gate lives An **auth-gated route** is a destination that needs a signed-in session, such as checkout in a second-hand marketplace app. Browsing and viewing listings are public; paying is not. When a signed-out user taps a shared link to buy a listing, the app has to show sign-in first and then take them where they meant to go. The decision *this route needs a session* belongs to the **navigation layer**, as metadata on the route, checked before anything is drawn. Putting the check inside the checkout screen means the screen starts to render, notices there is no session, and redirects. That flashes, leaves checkout half-built underneath sign-in, and makes every gated screen carry its own copy of the rule. A single gate at the point where stacks are installed treats links, notification taps and in-app taps the same way. ## The pending destination When the gate stops a route, it records what the user was trying to reach. This **pending destination** is the target stack itself, serialised as route names and IDs, for example `[browse, listing(123), checkout(123)]`. Three properties keep it safe: - **one slot**: if a second link arrives before sign-in finishes, the newer one replaces the older; - **used once**: it is cleared the moment it is resumed or abandoned; - **expiry**: a pending checkout from yesterday is not resumed today. Where it is stored matters, because sign-in often leaves the app. A browser-based OAuth 2.0 sign-in or an emailed magic link sends the user elsewhere, and while the app sits in the background the OS may terminate its process without warning. Anything held only in memory is then gone. | Where the pending destination lives | Survives sign-in in the browser | Survives the OS killing the app | |---|---|---| | In memory only | Usually | No | | Small persisted storage | Yes | Yes | | Asking the OS for the original link again | Not reliably | Not reliably | Small persisted storage is the fit: a few IDs, written when the gate fires and deleted when it is used. ## What the user sees while signed out The user lands on the **public listing** with sign-in presented over it, not on a bare sign-in screen with nothing behind it. Sign-in is a **conditional screen**: shown only when a session is needed, never the start destination. If the user cancels, they are left on the listing, which is a perfectly good outcome, and the pending checkout is cleared so it does not ambush them later. ## After sign-in: re-check, then replace A successful sign-in does not mean the pending destination is still right. Before resuming: 1. **Re-validate**: the listing may have been sold while the user typed a password; the signed-in account may turn out to be the listing's own seller, who cannot buy it. 2. **Replace, not push**: remove the sign-in flow and put checkout where it was, giving `[browse, listing(123), checkout(123)]`. Back from checkout then goes to the listing, never back into sign-in. 3. **Fall back gracefully**: if re-validation fails, open the listing with its current state. The common bug is resuming nothing: after sign-in the app resets to its start destination, and the user has to find the listing again. The other common bug is resuming blindly: opening checkout for an item that sold two minutes ago. ## What belongs elsewhere How one router library expresses signed-in and signed-out screen groups belongs to that library's own material. How the sign-in round trip returns to the app is the native OAuth 2.0 redirect design, and where tokens are stored is the session and credential design. Restoring an ordinary stack after the OS kills the app is the lifecycle design. This question keeps the decision only the navigation layer can make: *hold the destination as data, gate it, and resume it correctly.*

  • Why not let the checkout screen redirect to sign-in when it finds no session?
    The screen has already started rendering, so the user sees a flash of checkout, and sign-in ends up stacked above a half-built screen. Every gated screen also needs its own copy of the check and the redirect. A gate in the navigation layer decides before anything is drawn, applies to links, notification taps and in-app taps alike, and records the pending destination in one place.
  • What should happen if the account that signs in is the seller of the listing in the link?
    The pending destination must be re-validated, not replayed. A seller cannot buy their own item, so instead of checkout the app opens the listing, where the seller sees their own management view. The general rule: anything true when the link was tapped, availability, ownership, price, may have changed by the time sign-in finishes.
  • Two checkout links are tapped while the sign-in flow is still open; which one is resumed?
    The newest. The pending destination is a single slot, so the second link replaces the first; the user's latest choice wins. Queuing both would open two checkouts in a row, which nobody wants. Whatever is resumed is cleared after use, so neither link can fire again later.

A doorman who stops you for ID keeps your booking slip while you fetch it from the car, then walks you to the table you booked, not back to the lobby, after checking the table is still free.

  • After sign-in, send the user to the home screen; they can find the listing again.
  • Keep the pending destination only in memory, since sign-in takes a few seconds.
  • Put sign-in at the bottom of the stack so back from checkout returns to it.
  • Resume the pending destination without re-checking it; it was valid when tapped.
  • The OS will deliver the original link again once sign-in completes.