LEARN. PRACTICE. EXPLAIN.
Learning paths & interview practiceP
← Build an authenticated dashboard
BUILD → VERIFY → EXPLAIN · STEP 3 OF 6

Restore the session when the page loads

Ask the server who the user is before displaying private content.

UNDERSTAND

Bring these concepts with you

BUILD

Your implementation

  1. Implement restoreSession: publish a checking state, call /me, and then load invoices for a confirmed user.
  2. Treat 401 as signed out. Keep an unavailable server as a retryable session-check error instead of claiming the user has logged out.
  3. Register and log in, then refresh within 60 seconds. The same-origin API uses the backend project model; its session is restored by /me.
async function restoreSession() {
  // Check /me, then load data or publish the right recovery state.
}
Need a hint?
  • Use the generation counter to ignore results from an older request.
  • Clear displayed private rows while checking. A cached browser flag is not evidence of authentication.

Saved on this device · 0 / 6000 · Do not include passwords or private data.

VERIFY

Acceptance checks

From the folder containing your downloaded files, run:

node checks.mjs ./starter.mjs 3

This runs checks up to this step. Earlier steps must work first. Mark each result only after checking your implementation; the website does not run or grade it.

Record your attempt to enable the checklist and reference comparison.

Compare with the reference

Attempt the step first, then compare decisions and behavior. There can be more than one correct implementation.

EXPLAIN

Your interviewer asks

How do you distinguish signed out from a failed session check?

Say your answer aloud, then record the trade-offs and evidence in your notes above.

LOCAL VOICE REHEARSAL

Rehearse your step walkthrough aloud

Target pacing: 02:00 · Stays in this browser only; never uploaded.

00:00/ 02:00
AlifBay Prep