Skip to content

fix(auth): demo cookie no longer overrides real session#91

Merged
NicholaiVogel merged 2 commits intomainfrom
fix/demo-cookie-auth-priority
Feb 16, 2026
Merged

fix(auth): demo cookie no longer overrides real session#91
NicholaiVogel merged 2 commits intomainfrom
fix/demo-cookie-auth-priority

Conversation

@NicholaiVogel
Copy link
Copy Markdown
Contributor

Summary

  • Real WorkOS session now takes priority over the compass-demo cookie in getCurrentUser()
  • Stale demo cookie is automatically deleted when a real login is detected
  • Demo mode still works when WorkOS isn't configured or no real session exists

Context

After visiting /demo, the compass-demo cookie persists for 24 hours. If you then log in with real credentials, getCurrentUser() was still returning the demo user because the demo cookie check ran unconditionally before the WorkOS auth check.

Test plan

  • Visit /demo -- confirm demo org loads
  • Navigate to /login, sign in with real credentials
  • Confirm you land in your real org, not the demo org
  • Confirm compass-demo cookie is cleared after real login
  • bun run build passes

Add org-scoped data isolation across all server actions to
prevent cross-org data leakage. Add read-only demo mode with
mutation guards on all write endpoints.

Multi-tenancy:
- org filter on executeDashboardQueries (all query types)
- org boundary checks on getChannel, joinChannel
- searchMentionableUsers derives org from session
- getConversationUsage scoped to user, not org-wide for admins
- organizations table, members, org switcher component

Demo mode:
- /demo route sets strict sameSite cookie
- isDemoUser guards on all mutation server actions
- demo banner, CTA dialog, and gate components
- seed script for demo org data

Also: exclude scripts/ from tsconfig (fixes build), add
multi-tenancy architecture documentation.
The demo cookie was checked unconditionally before WorkOS auth,
so logging in with real credentials after visiting /demo still
returned the demo user. Now getCurrentUser() tries WorkOS first
and only falls back to the demo cookie when no real session
exists. Clears the stale cookie on real login.
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
compass 6f6ec5f Feb 16 2026, 05:17 AM

@NicholaiVogel NicholaiVogel merged commit c75b043 into main Feb 16, 2026
7 of 10 checks passed
@NicholaiVogel NicholaiVogel deleted the fix/demo-cookie-auth-priority branch February 16, 2026 05:21
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.

1 participant