Skip to content

Login logout flow#7

Merged
kentcdodds merged 3 commits into
mainfrom
cursor/login-logout-flow-b166
Feb 7, 2026
Merged

Login logout flow#7
kentcdodds merged 3 commits into
mainfrom
cursor/login-logout-flow-b166

Conversation

@kentcdodds
Copy link
Copy Markdown
Member

@kentcdodds kentcdodds commented Feb 7, 2026

Implement session-aware homepage navigation, enforce authentication redirects for account/login/signup pages, and add a functional logout feature.


Open in Cursor Open in Web


Note

Medium Risk
Touches authentication/session cookie handling and redirect behavior; mistakes could cause open redirects, broken login routing, or sessions not clearing correctly.

Overview
Adds session-aware auth flow across client and worker. The client App now fetches /session to render nav links as either Login/Signup or the signed-in email linking to /account, and the login form honors a safe redirectTo query param after successful auth.

On the server, introduces /login and /signup handlers that redirect authenticated users to /account, adds a /session JSON endpoint, and adds a POST /logout that clears the auth cookie. Unauthenticated /account requests now redirect to /login with a validated redirectTo back to the originally requested path, and Playwright E2E coverage is added for redirect + logout behavior.

Written by Cursor Bugbot for commit 0e30adf. This will update automatically on new commits. Configure here.

@cursor
Copy link
Copy Markdown

cursor Bot commented Feb 7, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

OAUTH_KV: KVNamespace;
APP_DB: D1Database;
ASSETS: Fetcher;
COOKIE_SECRET: string;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cursoragent I think this got removed because you did not cp .env.example to .env. That should be in the instructions and you should do that when creating a new environment before starting any work. Could you please update the instructions to do this? Don't update any scripts. Just make sure the instructions are clear that this needs to be done upon setup of the environment.

Copy link
Copy Markdown

@cursor cursor Bot Feb 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

  • Clarified agent setup to copy .env.example to .env before dev/tests.【F:AGENTS.md†L10-L18】
  • Strengthened local dev instructions to copy .env.example before starting work.【F:docs/agents/setup.md†L14-L22】

Testing

  • ⚠️ Not run (documentation-only change).

Open in Cursor Open in Web

@kentcdodds kentcdodds marked this pull request as ready for review February 7, 2026 00:18
Comment thread client/client-routes.tsx
@cursor
Copy link
Copy Markdown

cursor Bot commented Feb 7, 2026

Bugbot Autofix prepared fixes for 1 of the 1 bugs found in the latest run.

  • ✅ Fixed: Open redirect vulnerability via protocol-relative URLs
    • Added explicit rejection of protocol-relative redirect targets so only single-slash relative paths are accepted.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is ON. A Cloud Agent has been kicked off to fix the reported issue.

OAUTH_KV: KVNamespace;
APP_DB: D1Database;
ASSETS: Fetcher;
COOKIE_SECRET: string;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

COOKIE_SECRET removed from worker environment types

High Severity

The COOKIE_SECRET binding was accidentally removed from Cloudflare.Env and the NodeJS.ProcessEnv extension was also removed. The codebase relies on COOKIE_SECRET in server/handler.ts via appEnv.COOKIE_SECRET, and the Zod schema in types/env-schema.ts still validates its presence. This breaks TypeScript type safety — code accessing the cookie secret will now have type errors or lose type checking. As noted in the PR discussion, this happened because .env.example wasn't copied to .env before running wrangler types.

Fix in Cursor Fix in Web

Comment thread AGENTS.md
## Agent setup

- Install dependencies with `bun install`.
- Copy `.env.example` to `.env` before running dev or tests.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cursor, great job, now do this and undo your changes to the worker-configuration.d.ts file.

Copy link
Copy Markdown

@cursor cursor Bot Feb 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bugbot Autofix prepared fixes for 1 of the 1 bugs found in the latest run.

  • ✅ Fixed: COOKIE_SECRET removed from worker environment types
    • Regenerated the Wrangler types with COOKIE_SECRET present, restoring the Cloudflare.Env and NodeJS.ProcessEnv declarations.

Create PR

Open in Cursor Open in Web

cursoragent and others added 3 commits February 6, 2026 23:23
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
@kentcdodds kentcdodds force-pushed the cursor/login-logout-flow-b166 branch from 4441336 to 0e30adf Compare February 7, 2026 06:23
@kentcdodds kentcdodds merged commit d501266 into main Feb 7, 2026
7 checks passed
@kentcdodds kentcdodds deleted the cursor/login-logout-flow-b166 branch February 7, 2026 06:24
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.

2 participants