Repository navigation
fix(settings): allow owner require_open_shift PUT - #1120
Conversation
Allow authorized callers to update require_open_shift via PUT /api/settings/require_open_shift with strict boolean validation normalizing to 'true' or 'false'. Fixes #1072
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@greptile review |
|
Intent
Verify and implement the surgical fix for FreeOpenSourcePOS/FloCafe issue #1072 ("Owner cannot update require_open_shift via settings API"): in
main/routes/settings.ts, allow authorized owner/settings callers to updaterequire_open_shiftviaPUT /api/settings/require_open_shiftwith strict Boolean representation ("true"/"false"or booleantrue/falsestored as"true"/"false") consistent withmain/services/shift-session-gate.ts. Deliver via theno-mistakespipeline as its own PR withFixes #1072in the PR summary.What Changed
require_open_shifttoALLOWED_WILDCARD_KEYSinmain/routes/settings.tsand validatedPUT /api/settings/require_open_shiftpayloads to accept only booleantrue/falseor string"true"/"false", normalizing the persisted setting value to"true"or"false".tests/cash-sessions.test.tsto exercisePUT /api/settings/require_open_shiftfor role authorization (403for cashier), invalid payload rejection (400), and toggling shift-session enforcement via boolean and string values (200).Fixes #1072
Risk Assessment
✅ Low: The change is a small, well-bounded allowlist addition and strict boolean validation on PUT /api/settings/require_open_shift that matches shift-session-gate.ts and is covered by behavioral API tests.
Testing
Built the backend (
npm run build), ran the focused integration test suites (npm run test:cash-sessions,npm run test:orders-layout-settings, andnpm run test:theme-mode-settings), and stood up the compiled Express API server against an isolated SQLite database on port 34172 to drive all five happy-path, adversarial, and shift-gate enforcement scenarios live over HTTP, recording the full request/response and database state transcript in~/.no-mistakes/evidence/01M4VBY10KF35JC378Q1E6PR5A/require-open-shift-live-api-transcript.json(backend API change only; no UI surface modified).Evidence: Live Express API & SQLite transcript for PUT /api/settings/require_open_shift
{ "serverPort": 34172, "stringToggle": { "s1_enable": { "status": 200, "dbValue": "true" }, "s1_get": { "status": 200, "value": "true" }, "s1_disable": { "status": 200, "dbValue": "false" } }, "booleanToggle": { "s2_enable": { "status": 200, "dbValue": "true" }, "s2_disable": { "status": 200, "dbValue": "false" } }, "invalidValuesRejected": ["yes", "1", "0", "", 1, 0, null, {}], "unauthorizedRoleRejected": { "status": 403, "permission": "settings.manage", "dbValue": "false" }, "shiftGateEnforcement": { "s5_payBlocked": { "status": 409, "display_code": "cash_session_required" }, "s5_payAllowed": { "status": 200, "payment_status": "paid" } } }Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
npm run buildnpm run test:cash-sessionsnpm run test:orders-layout-settingsnpm run test:theme-mode-settingsELECTRON_RUN_AS_NODE=1 ./node_modules/.bin/electron -e '<live Express + SQLite verification on port 34172>'✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.