Repository navigation
feat(auth): fast cashier switch by PIN - #1392
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
PR Summary by QodoAdd PIN quick switching and terminal lock with protected approvals
AI Description
Diagram
High-Level Assessment
Files changed (53)
|
Code Review by Qodo
1.
|
Allow 4-6 digit PINs for all staff roles to support tile-based PIN quick user switching on the lock/login screen while keeping all approval paths strictly restricted to active owner/manager PINs. Fixes #1338
- Use non-blocking per-request rate limit on POST /api/auth/pin-login while preserving per-user lockout - Serialize per-user PIN verification with withPinVerificationLock and audit missing credential requests - Re-read bill/order state and compute charge breakdowns inside the write transaction on PATCH /api/bills/:id/charges - Guard GET /api/settings/auto_lock_minutes with requireAnyPermission across staff roles - Pass explicit Bearer token to POST /auth/logout before clearing storage on lock/logout - Exclude autoLockMinutes from localStorage persistence, reset on session changes, and guard stale save rollbacks - Update kitchenDeliveryOverrideInvalid across all 24 locales to use Staff Approval PIN wording
…c.ts` line 270 to assert `page.getByText('Invalid Staff Approval PIN')` instead of `'Invalid manager PIN'`, matching the updated `pos.kitchenDeliveryOverrideInvalid` translation (`"Invalid Staff Approval PIN. Please try again."`) rendered by `PaymentModal.tsx` when `POST /api/bills/:id/payments` returns 403 `Invalid manager PIN`. The downstream `End-to-End Playwright Tests` and `Required Checks Gate` CI failures were caused by this Shard 1/4 E2E failure. Verification run and passed: - `npm run lint` - `npm run build && npm run build:frontend` - `npm run i18n:check` - `cd frontend && npx playwright test --config=playwright.config.ts --project=chromium e2e/approval-manager-selection.spec.ts e2e/pin-quick-switch.spec.ts` (4 passed) - `cd frontend && npx playwright test --config=playwright.config.ts --project=chromium e2e/kitchen-delivery-payment-retry.spec.ts e2e/kitchen/kitchen-delivery-billing-gate.spec.ts` (5 passed) - `node scripts/ci/check-changed-format.cjs --base 1278f91` - `git diff --check`
91478eb to
4abd1be
Compare
Fixes #1338
Intent
Implement and verify issue #1338 (
feat(auth): PIN quick user switch with user picker (PIN for all roles, approvals stay owner/manager)) and open a PR targetingmainwithout merging it:pin_hash) and allow it for every staff role (main/routes/staff.ts~L314). It doubles as the sign-in PIN.id,name,roleonly) as tiles. Tap a user, then enter that user's PIN. The PIN is checked only against the selected user (POST /api/auth/pin-logintaking{ user_id, pin }), never by scanning all users, so two users may share the same PIN.1,5,15, or30minutes).kitchenDeliveryOverridePrompt, which still says "Manager PIN", across all 24 locales.docs/architecture/authentication-and-authorization.mdanddocs/reference/roles-and-permissions.md.What Changed
owner,manager,cashier,server,chef) and addGET /api/auth/pin-usersandPOST /api/auth/pin-loginwith per-account and per-IP login rate limiting, serialized PIN verification, andauth_audit_logrecording (event_type = 'pin_login').auto_lock_minutesidle auto-lock store setting (0,1,5,15, or30minutes) that revokes the active session token while preserving the unfinished POS cart and clearing privileged cart adjustments, modal state, and stale async callbacks across session boundaries.ownerandmanagerrole filtering on every Staff Approval PIN candidate query and in-transaction re-validation (refunds, item voids, order and item discounts, order-status overrides, kitchen-delivery overrides, and charge waivers), and update PIN vs. Staff Approval PIN translations and documentation across all 24 locales.Risk Assessment
✅ Low: All 56 changed files were reviewed against the issue #1338 acceptance criteria and repository invariants. Per-user PIN assignment is opened to all staff roles while all approval and override paths (approvers list, refunds, item voids, order/item/bill discounts, order-status overrides, kitchen-delivery overrides, and charge waivers) strictly enforce active owner/manager role eligibility both during async pre-verification and inside write transactions. Selected-user PIN login serializes verification per target account, enforces both per-IP+user and cross-IP per-account rate-limit lockouts, and records auth_audit_log events. Terminal lock and user switching preserve unsubmitted POS cart items while clearing privileged cart adjustments, modal state, and stale async callbacks.
Testing
Built the backend and static desktop frontend, ran targeted backend integration suites (
test:pin-quick-switch,test:staff-authz,test:staff-approvers-directory,test:discount-kitchen-approver-identity,test:cancel-override,test:refunds,test:translations,test:menu-surface,test:schema-health,test:migration-registry, andbackup-restore-production.test.ts) plus Playwright E2E suites (e2e/pin-quick-switch.spec.ts,e2e/approval-manager-selection.spec.ts, ande2e/database-export-import.spec.ts), and drove 5 live end-to-end scenarios in Chromium against the running server with 8 screenshots and structured JSON evidence captured in the evidence directory; all checks and scenarios passed.Evidence: Live end-to-end verification API and state evidence summary
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 test:pin-quick-switchnpm run test:staff-authznpm run test:staff-approvers-directorynpm run test:discount-kitchen-approver-identitynpm run test:translationsnode tests/run-electron-node-test.cjs tests/backup-restore-production.test.tsnpm run test:cancel-overridenpm run test:refundsnpm run test:menu-surfacenpm run test:schema-healthnpm run test:migration-registrycd frontend && npx playwright test e2e/pin-quick-switch.spec.ts e2e/approval-manager-selection.spec.ts e2e/database-export-import.spec.ts --project=chromiumLive Chromium end-to-end verification of all 5 scenarios againstnode tests/e2e-server.cjswith screenshots and JSON evidence saved under~/.no-mistakes/evidence/01M62C1F6QJAPNHG450HF38KFF✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.