fix: persist welcome-dismissed flag in database instead of session#1197
fix: persist welcome-dismissed flag in database instead of session#1197scottbuscemi wants to merge 1 commit into
Conversation
The welcome modal kept reappearing because the hasSeenWelcome flag was stored in the Astro session, which is ephemeral. When the session expired or rotated, the flag was lost and the modal showed again. Persist the welcomeDismissed flag in the user's data JSON column so it survives session expiry. Add a regression test that simulates a fresh session after dismissal and verifies isFirstLogin remains false.
|
PR template validation failedPlease fix the following issues by editing your PR description:
See CONTRIBUTING.md for the full contribution policy. |
|
All contributors have signed the CLA ✍️ ✅ |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
docs | 5a0ebfb | May 28 2026, 07:03 PM |
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/blocks
@emdash-cms/cloudflare
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-demo-cache | 5a0ebfb | May 28 2026, 07:04 PM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-playground | 5a0ebfb | May 28 2026, 07:06 PM |
ascorbic
left a comment
There was a problem hiding this comment.
You'll need to use the PR template and sign the CLA
| import { authMeActionBody } from "#api/schemas.js"; | ||
|
|
||
| export const GET: APIRoute = async ({ locals, session }) => { | ||
| import { UserRepository } from "../../../../database/repositories/user.js"; |
There was a problem hiding this comment.
| import { UserRepository } from "../../../../database/repositories/user.js"; | |
| import { UserRepository } from "#db/repositories/user.js"; |
|
recheck |
Problem
The "Welcome to EmDash" modal keeps reappearing on every login. After clicking "Get Started", the modal is dismissed for the current session but shows up again on the next login or when the session expires/rotates.
Root Cause
The
hasSeenWelcomeflag was stored in the Astro session (session?.set("hasSeenWelcome", true)), which is ephemeral. On Cloudflare, sessions are backed by KV with a TTL. When the session expires and a new one is created on the next login, the flag is lost andGET /auth/mereportsisFirstLogin: true, causing the modal to reappear.Fix
Persist the
welcomeDismissedflag in the user'sdataJSON column in the database instead of the session. Thedatacolumn already exists on theuserstable as a general-purpose JSON store.GET handler: reads
user.data?.welcomeDismissedinstead ofsession?.get("hasSeenWelcome")POST handler: writes
{ welcomeDismissed: true }to the user'sdatacolumn viaUserRepository.update()instead ofsession?.set()Changes
packages/core/src/astro/routes/api/auth/me.ts— switch from session to database persistencepackages/core/tests/unit/auth/me-welcome-dismiss.test.ts— regression test that creates a user, dismisses the welcome, simulates a fresh session, and verifiesisFirstLoginremainsfalsePlayground preview won't show this being resolved since it creates a new user each time...