Skip to content

Allow anonymous users to read lessons#11

Merged
exekias merged 2 commits into
mainfrom
anon-read-lessons
May 27, 2026
Merged

Allow anonymous users to read lessons#11
exekias merged 2 commits into
mainfrom
anon-read-lessons

Conversation

@exekias
Copy link
Copy Markdown
Member

@exekias exekias commented May 26, 2026

Summary

Closes #9.

Signed-out visitors can now open and read any /lessons/<slug> page instead of being bounced to the landing page. Every interactive action stays gated behind auth, but in context — replaced with a sign-in CTA that returns to the current lesson.

  • Lesson page (app/lessons/[slug]/page.tsx): dropped the if (!session) redirect("/"). Prose + prev/next nav render for everyone; progress lookup is skipped when signed out.
  • Run / Check (RunBlock.tsx, Check.tsx): when signed out, the action button is replaced by an inline "Sign in to run" / "Sign in to check" CTA. An isSignedIn flag + lesson callbackURL are threaded through buildLessonComponents.
  • Sandbox (SandboxSection.tsx + new SandboxSignInPrompt.tsx): anonymous visitors get a disabled terminal placeholder with a prominent "Sign in to start the sandbox" button — ensureBranchForLesson is not called, so no Xata branch is provisioned.
  • SignInButton (app/sign-in-button.tsx): now takes optional callbackURL (default /dashboard), a variant (default | inline), and a custom label via children. Existing landing-page usage is unchanged.
  • API routes keep their 401 guards — no changes there.

Test plan

  • tsc --noEmit and eslint pass.
  • Anonymous GET /lessons/select-basics returns 200 (no redirect) and renders the prose, "Sign in to run", "Sign in to check", and "Sign in to start the sandbox" CTAs; no ▶ Run button and no sandbox branch created.
  • Signed in: Run/Check buttons and live terminal still work as before.
  • Clicking any CTA signs in via GitHub and lands back on the same lesson.

🤖 Generated with Claude Code

Drop the redirect that bounced signed-out visitors off lesson pages.
The prose and prev/next nav now render for everyone, while interactive
pieces stay gated in context: Run/Check buttons become an inline
"Sign in" CTA, and the sandbox shows a disabled placeholder with a
"Sign in to start the sandbox" button instead of provisioning a Xata
branch. All CTAs return to the current lesson after sign-in.

Closes #9

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
learn-postgres Ready Ready Preview May 26, 2026 3:55pm

@exekias exekias merged commit f390428 into main May 27, 2026
3 checks passed
@exekias exekias deleted the anon-read-lessons branch May 27, 2026 07:38
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.

Allow anonymous users to read lessons (sign-in CTA for actions + shell)

1 participant