Repository navigation
fix: changing the family code signs other devices out; recipes and meal plans merge into the shopping list - #417
Merged
Conversation
…al plans merge into the shopping list Changing the join code was a browser-side UPDATE of families.join_code. The confirmation promised that every connected device would need to rejoin, but sessions last a year and revokeFamilySessions had no caller, so a lost phone stayed signed in. POST /api/family/join-code now rotates the code (crypto.randomInt, settings PIN required) and revokes every other session of the family, keeping the caller's. "Add to shopping list" on a recipe and "generate shopping list" on the meal plan did a plain insert, so items already on the list were added a second time. addOrMergeShoppingItems moves out of the server-only lib/shopping-enrich.ts into lib/shopping-add.ts, which works with either Supabase client. Both hooks now go through it, and they invalidate the shopping page's real query key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01STyQ3UYK3VBFvcZ3Je5jCr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two bugs that came up while comparing Kinboard with Yuvomi.
1. Changing the family code didn't sign anyone out (security).
families.join_code.revokeFamilySessionsinlib/session.tswas written "for a join-code rotation" but had no callers. After a lost phone, a new code only stopped new devices from joining.POST /api/family/join-code:crypto.randomInt. The browser version usedMath.random.2. Sending a recipe or the meal plan to the shopping list created duplicates.
useAddRecipeToShoppingListanduseGenerateShoppingFromMealPlandid a plain.insert. Milk already on the list was added a second time, and the same recipe added twice doubled every item.lib/shopping-merge.tsalready had the right rules, but only the assistant API used them.addOrMergeShoppingItemsmoves from the server-onlylib/shopping-enrich.tsinto a new browser-safelib/shopping-add.ts. ItsshoppingStoreworks with either Supabase client.shopping-enrich.tsre-exports it, so the server callers are unchanged.queryKeys.shoppingItems) instead of["shopping_items", …], which nothing reads.Type of change
Test plan
e2e/join-code-rotation.spec.ts: revokes others but keeps the caller, needs a session and PIN, uses the session's family only, crypto code, the hook goes through the route, strings exist in all localese2e/shopping-merge-ui.spec.ts: merges into an existing item and inserts a new one through a fake Supabase client; both hooks use the merge;shopping-add.tsimports nothing server-onlynpm run lint,npx tsc --noEmit,node scripts/check-changelog-sections.mjsScreenshots
Text-only change to the existing confirmation dialog.
Checklist
npm run lintpassesmessages/en.jsonandmessages/de.json(and fr)webapp/docker/migration*.sqlfile (none needed)CHANGELOG.mdupdated under[Unreleased](Fixed and Security)Generated by Claude Code