Skip to content

feat(auth): add quick PIN sign-in and mode toggle - #1524

Merged
khaira777 merged 5 commits into
mainfrom
fm/flocafe-quick-pin-signin-toggle
Nov 8, 2026
Merged

khaira777 merged 5 commits into
mainfrom
fm/flocafe-quick-pin-signin-toggle

Conversation

@khaira777

@khaira777 khaira777 commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1516

Intent

can we also add quick sign in on the kds screen as well simialr to main pos? do the same for server app too, also the quick sign in and normal sign in , make a toggle somewhere so its not long vertically and is easy to use?

What Changed

  • Added GET /api/auth/pin-users and POST /api/auth/pin-login on the standalone KDS (:3002) and Server App (:3003) servers, plus ?scope=kds filtering on :3001, enforcing kitchen.use with active station checks on KDS and server-app.use on Server App along with per-user PIN verification locks and IP+user rate-limit lockouts.
  • Added quick PIN sign-in user pickers, PIN entry/numpad controls, and a segmented toggle between Quick Sign-In and email/password sign-in across POS (/auth/login), KDS (KdsLoginForm, useKdsConnection, /kds-standalone), and Server App (/server-standalone).
  • Updated authentication and API reference documentation and expanded unit and Playwright E2E coverage in tests/pin-quick-switch.test.ts and frontend/e2e/pin-quick-switch.spec.ts.

Risk Assessment

✅ Low: The PIN quick sign-in endpoints, permission/station filtering, and segmented mode toggles across POS, KDS, and Server App are well-bounded, consistent with existing authentication and rate-limiting contracts, and all prior review findings are resolved.

Testing

Ran npm run test:pin-quick-switch, built the backend and static frontend (npm run build && npm run build:frontend), executed the Playwright E2E suite frontend/e2e/pin-quick-switch.spec.ts against isolated Main POS, KDS, and Server App servers, and drove an interactive Chromium session capturing 10 screenshots covering the Quick Switch / Password mode toggle, role-filtered user tile pickers, wrong-PIN error handling, and authenticated workspaces across all three surfaces.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Main POS login screen renders a compact Quick Switch / Password mode toggle instead of stacking both forms vertically, switches between views cleanly, and completes POS lock and PIN quick-switch flow ✅ pass live 01-pos-login-quick-signin-toggle.png, 02-pos-login-password-mode.png, and frontend/e2e/pin-quick-switch.spec.ts
KDS login screen renders the Quick Switch / Password mode toggle, displays only PIN-configured staff authorized for KDS (excluding cashier/server and chefs with only inactive stations), and signs into… ✅ pass live 03-kds-quick-signin-picker.png, 05-kds-password-mode.png, 06-kds-authenticated-workspace.png, and frontend/e2e/pin-quick-switch.spec.ts
Server App login screen renders the Quick Switch / Password mode toggle, displays only PIN-configured staff with server-app.use permission (excluding cashier/chef), and signs into the tableside orderi… ✅ pass live 07-server-app-quick-signin-picker.png, 09-server-app-password-mode.png, 10-server-app-authenticated-workspace.png, and frontend/e2e/pin-quick-switch.spec.ts
Adversarial PIN login checks on KDS and Server App reject wrong PINs (clearing the input and surfacing an inline error), enforce per-user/IP 5-attempt rate-limit lockouts, and reject unauthorized role… ✅ pass live 04-kds-pin-keypad-and-wrong-pin-error.png, 08-server-app-pin-keypad-and-wrong-pin-error.png, and tests/pin-quick-switch.test.ts

Main POS Login - Quick Sign-In Mode Toggle & User Picker
Main POS Login - Password Mode via Toggle
KDS Standalone - Quick Sign-In Mode Toggle & Kitchen-Filtered User Picker
KDS Standalone - PIN Keypad & Wrong-PIN Error State
KDS Standalone - Password Mode via Toggle
KDS Standalone - Authenticated Kitchen Workspace after PIN Login
Server App - Quick Sign-In Mode Toggle & Service-Filtered User Picker
Server App - PIN Keypad & Wrong-PIN Error State
Server App - Password Mode via Toggle
Server App - Authenticated Ordering Workspace after PIN Login

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 2 issues found → auto-fixed ✅
  • ⚠️ frontend/src/components/kds/KdsLoginForm.tsx:51 - In KdsLoginForm.tsx, handlePinLogin failures are stored in conn.loginError (frontend/src/hooks/useKdsConnection.ts:787), while the local pinError state (frontend/src/components/kds/KdsLoginForm.tsx:21) is never set to a non-empty string and displayPinError reads pinError || conn.loginError (KdsLoginForm.tsx:51). As a result, all setPinError('') calls in KdsLoginForm.tsx (lines 26, 31, 36, 43, 76, 94, 135, 178, 251) are no-ops: after a failed PIN attempt, conn.loginError remains visible when typing a new PIN, cancelling (pin-login-cancel), selecting a different staff tile, or switching to the Email/Password tab (signin-mode-password), and a failed Email/Password attempt likewise leaks conn.loginError into the PIN form when switching to signin-mode-pin. In addition, switching to signin-mode-password in frontend/src/components/kds/KdsLoginForm.tsx:92-95 and frontend/src/app/server-standalone/page.tsx:1339-1342 does not reset selectedPinUser or pin (unlike frontend/src/app/auth/login/page.tsx:338-340), leaving a partially typed PIN and selected user active when toggling back to PIN mode.
  • ⚠️ frontend/src/components/kds/KdsLoginForm.tsx:27 - KdsLoginForm.tsx (lines 27, 165, 172, 179) and server-standalone/page.tsx (lines 831, 1412, 1419, 1426) display {pin.length}/8 and allow entering up to 8 digits on the PIN keypad and input (maxLength={8}, prev.length < 8, .slice(0, 8)). However, staff PINs in FloCafe are strictly 4-6 digits (main/routes/staff.ts:92 and frontend/src/app/auth/login/page.tsx:390,396,411,436), and all three backend PIN login handlers (main/kds-server.ts:478, main/server-app.ts:474, main/routes/auth.ts:475) reject any PIN not matching /^\d{4,6}$/ with HTTP 401 (invalid_pin_format) while incrementing incrementFailedLogin(pinRateKey) toward lockout. Cap the PIN input, keypad, and counter at 6 digits in both components to match the backend contract and main POS login.

🔧 Fix applied.
✅ Re-checked - no issues remain.

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Staff on Main POS login screen toggles between Quick Switch (PIN) and Password modes without vertical stacking, locks POS, and quick-switches to cashier via PIN keypad while preserving cart ✅ pass live pos-login-quick-pin-mode.png, pos-login-password-mode.png, frontend/e2e/pin-quick-switch.spec.ts
Kitchen staff on KDS screen sees the Quick Switch / Password mode toggle, views only kitchen-authorized PIN staff tiles, toggles between modes, and signs in with a 4-6 digit PIN into the KDS workspace ✅ pass live kds-quick-signin-picker.png, kds-quick-signin-keypad.png, kds-password-signin-mode.png, kds-signed-in-workspace.png, frontend/e2e/pin-quick-switch.spec.ts
Service staff on Server App screen sees the Quick Switch / Password mode toggle, views only server-app-authorized PIN staff tiles, toggles between modes, and signs in with a 4-6 digit PIN into the tab… ✅ pass live server-app-quick-signin-picker.png, server-app-quick-signin-keypad.png, server-app-password-signin-mode.png, server-app-signed-in-workspace.png, frontend/e2e/pin-quick-switch.spec.ts
Adversarial role/station and PIN checks: non-kitchen staff and chefs with only inactive stations are excluded and rejected (403) on KDS PIN login, non-server-app staff are excluded and rejected (403)… ✅ pass live npm run test:pin-quick-switch, frontend/e2e/pin-quick-switch.spec.ts
  • npm run test:pin-quick-switch
  • npm run test:rtl-setup-auth-settings
  • npm run test:rtl-kds-server-whatsapp
  • npm run test:auth-ui-deterministic
  • cd frontend && CI=1 E2E_BASE_URL=http://127.0.0.1:43101 E2E_KDS_BASE_URL=http://127.0.0.1:43102 E2E_SERVER_APP_BASE_URL=http://127.0.0.1:43103 npx playwright test e2e/pin-quick-switch.spec.ts --config=playwright.config.ts --project=chromium

✅ No issues found.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Main POS login screen renders a compact Quick Switch / Password mode toggle instead of stacking both forms vertically, switches between views cleanly, and completes POS lock and PIN quick-switch flow ✅ pass live 01-pos-login-quick-signin-toggle.png, 02-pos-login-password-mode.png, and frontend/e2e/pin-quick-switch.spec.ts
KDS login screen renders the Quick Switch / Password mode toggle, displays only PIN-configured staff authorized for KDS (excluding cashier/server and chefs with only inactive stations), and signs into… ✅ pass live 03-kds-quick-signin-picker.png, 05-kds-password-mode.png, 06-kds-authenticated-workspace.png, and frontend/e2e/pin-quick-switch.spec.ts
Server App login screen renders the Quick Switch / Password mode toggle, displays only PIN-configured staff with server-app.use permission (excluding cashier/chef), and signs into the tableside orderi… ✅ pass live 07-server-app-quick-signin-picker.png, 09-server-app-password-mode.png, 10-server-app-authenticated-workspace.png, and frontend/e2e/pin-quick-switch.spec.ts
Adversarial PIN login checks on KDS and Server App reject wrong PINs (clearing the input and surfacing an inline error), enforce per-user/IP 5-attempt rate-limit lockouts, and reject unauthorized role… ✅ pass live 04-kds-pin-keypad-and-wrong-pin-error.png, 08-server-app-pin-keypad-and-wrong-pin-error.png, and tests/pin-quick-switch.test.ts
  • npm run test:pin-quick-switch
  • npm run build && npm run build:frontend
  • cd frontend && CI=1 E2E_BASE_URL=http://127.0.0.1:43001 E2E_KDS_BASE_URL=http://127.0.0.1:43002 E2E_SERVER_APP_BASE_URL=http://127.0.0.1:43003 npx playwright test e2e/pin-quick-switch.spec.ts --config=playwright.config.ts --project=chromium --retries=0
  • Live Playwright Chromium verification against isolated tests/e2e-server.cjs instances on ports 44001-44003 capturing 10 screenshots across Main POS, KDS, and Server App
✅ **Document** - passed

✅ No issues found.

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

✅ No issues found.

@qodo-code-review

Copy link
Copy Markdown

ⓘ Your Qodo trial ends soon. Ask your workspace admin to set up billing to keep reviews running after the trial. Manage billing

@coderabbitai

coderabbitai Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Add quick PIN sign-in and compact mode toggles across POS, KDS, and Server App

✨ Enhancement 🧪 Tests 🕐 40+ Minutes

Grey Divider

AI Description

• Add permission-scoped PIN sign-in to KDS and Server App without removing password sign-in.
• Replace stacked sign-in forms with a PIN/password toggle when eligible staff are available.
• Cover authorization, failed attempts, and sign-in flows with integration and browser tests.
Diagram

graph TD
  POS["POS Sign-In"] --> MAIN["Main Auth API"] --> HELPERS["PIN Utilities"] --> DB[("Staff Database")]
  KDS["KDS Sign-In"] --> KDSAPI["KDS Auth API"] --> HELPERS
  SERVER["Server Sign-In"] --> SERVERAPI["Server Auth API"] --> HELPERS
  KDS --> MAIN
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Extract a shared PIN authentication service
  • ➕ Centralizes credential verification, lockout, and audit behavior across all three listeners.
  • ➕ Reduces the chance of security behavior drifting between surfaces.
  • ➖ Broadens an authentication-sensitive refactor beyond the new standalone routes.
  • ➖ Still needs listener-specific permission, station, and response handling.

Recommendation: The PR's listener-local routes are reasonable for this change: they reuse existing PIN security utilities while keeping each surface's access policy explicit. Consider a shared authentication service if more PIN surfaces or policy changes follow; extracting one now would widen the security-sensitive change.

Files changed (12) +1889 / -229

Enhancement (8) +1486 / -189
page.tsxMake POS PIN and password sign-in mutually exclusive +117/-63

Make POS PIN and password sign-in mutually exclusive

• Adds a segmented sign-in mode toggle when PIN users exist, defaulting to PIN mode while preserving the password form. Clears mode-specific state on switching and bounds the staff tile list height.

frontend/src/app/auth/login/page.tsx

page.tsxConnect standalone KDS to its PIN routes +17/-9

Connect standalone KDS to its PIN routes

• Supplies standalone PIN directory and login endpoints to the KDS connection hook. Limits the 401 reload handler to requests carrying the current stored token so failed PIN attempts remain visible.

frontend/src/app/kds-standalone/page.tsx

page.tsxAdd Server App PIN picker and shared session setup +362/-62

Add Server App PIN picker and shared session setup

• Adds a sign-in mode toggle, staff tiles, and a 4–6 digit PIN form with inline failure feedback. Routes PIN and password successes through the same session and suspended-draft handling.

frontend/src/app/server-standalone/page.tsx

KdsLoginForm.tsxAdd KDS quick sign-in alongside password mode +316/-53

Add KDS quick sign-in alongside password mode

• Adds a compact mode toggle, eligible staff tiles, and a 4–6 digit PIN keypad. Clears PIN and error state when editing, changing staff, or switching modes.

frontend/src/components/kds/KdsLoginForm.tsx

useKdsConnection.tsSupport scoped KDS PIN discovery and authentication +99/-0

Support scoped KDS PIN discovery and authentication

• Fetches eligible PIN users through dashboard or standalone endpoints and adds a PIN login handler. The handler maps failures to login feedback and establishes the existing KDS session and WebSocket connection on success.

frontend/src/hooks/useKdsConnection.ts

kds-server.tsExpose permission-gated PIN authentication on KDS +298/-0

Expose permission-gated PIN authentication on KDS

• Adds a PIN staff directory and selected-user PIN login to the standalone KDS listener. Enforces feature, kitchen permission, active-station, audit, and per-IP/user failed-attempt controls before issuing a token.

main/kds-server.ts

auth.tsScope the main PIN staff directory for KDS +22/-2

Scope the main PIN staff directory for KDS

• Adds 'scope=kds' filtering to return only staff eligible for kitchen access and active-station requirements. Returns an empty directory when KDS is disabled without changing the default POS directory.

main/routes/auth.ts

server-app.tsExpose permission-gated PIN authentication on Server App +255/-0

Expose permission-gated PIN authentication on Server App

• Adds a PIN staff directory and selected-user PIN login to the standalone Server App listener. Applies feature and 'server-app.use' gates, audit records, and per-IP/user failed-attempt controls before token issuance.

main/server-app.ts

Tests (2) +351 / -3
pin-quick-switch.spec.tsExercise sign-in toggles and PIN flows in the browser +125/-3

Exercise sign-in toggles and PIN flows in the browser

• Extends POS toggle coverage and signs in through the standalone KDS and Server App pickers. Checks staff filtering, failed-PIN feedback, successful navigation, and fixture cleanup.

frontend/e2e/pin-quick-switch.spec.ts

pin-quick-switch.test.tsTest standalone PIN routes and access boundaries +226/-0

Test standalone PIN routes and access boundaries

• Starts KDS and Server App listeners and checks eligible staff filtering, invalid requests, denied permissions and stations, failed PINs, and successful logins. Also tests the main API's KDS-scoped directory.

tests/pin-quick-switch.test.ts

Documentation (2) +52 / -37
authentication-and-authorization.mdDocument PIN authentication across all three listeners +19/-8

Document PIN authentication across all three listeners

• Describes scoped staff directories, standalone permission gates, sign-in toggles, and the two additional token-issuance paths.

docs/architecture/authentication-and-authorization.md

api.mdAdd standalone PIN endpoint contracts +33/-29

Add standalone PIN endpoint contracts

• Documents the main API's KDS directory scope and both new KDS and Server App routes, including authorization and error responses. Updates route inventory counts.

docs/reference/api.md

@khaira777 khaira777 changed the title feat: add quick PIN sign-in to KDS and Server App with sign-in mode toggle feat(auth): add quick PIN sign-in and mode toggle Nov 8, 2026
@qodo-code-review

qodo-code-review Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Staff can reuse a previous user's password 🐞 Bug ⛨ Security
Description
The KDS PIN-mode handler leaves conn.loginPassword intact, and the Server App PIN-mode handler
likewise leaves its password state intact. If someone enters password credentials, switches to PIN
and another staff member signs in, the old credentials remain available when the password form is
reopened, including after logout.
Code

frontend/src/components/kds/KdsLoginForm.tsx[R71-74]

+              onClick={() => {
+                setSignInMode('pin');
+                conn.setLoginError?.('');
+              }}
Relevance

●●● Strong

Deterministic credential-clearing fix mirroring the POS login handler that already clears email and
password in the same PR; no rejection precedent.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new KDS mode handler clears only the error, although its password input reads persistent hook
state; KDS logout does not clear that state. The Server App mode handler also leaves email/password
untouched, and its logout clears only the token and user. The POS mode handler provides a
contrasting path that explicitly clears both credential fields.

frontend/src/components/kds/KdsLoginForm.tsx[71-74]
frontend/src/components/kds/KdsLoginForm.tsx[303-313]
frontend/src/hooks/useKdsConnection.ts[817-830]
frontend/src/app/server-standalone/page.tsx[1321-1324]
frontend/src/app/server-standalone/page.tsx[880-888]
frontend/src/app/auth/login/page.tsx[316-320]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Switching to PIN mode hides but retains entered password credentials on shared KDS and Server App screens.
## Fix Focus Areas
- frontend/src/components/kds/KdsLoginForm.tsx[71-74]
- frontend/src/app/server-standalone/page.tsx[1321-1324]
## Recommended Fix
Clear the controlled email and password values when entering PIN mode in both screens. Verify that returning to password mode after a PIN sign-in and logout cannot restore a previous user's credentials.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


2. External guides miss PIN sign-in ⊘ Outdated
Description
docs/reference/api.md now documents PIN picker and login routes on the standalone KDS and Server
App servers, but the docs.flopos.com KDS route inventory and authentication endpoint list still
enumerate only password login. Developers using those guides cannot find the new routes or their
permission gates; update the external guides alongside this reference.


Informational

3. Sign-in form jumps to PIN mode while staff type 🐞 Bug ≡ Correctness
Description
KdsLoginForm defaults a null signInMode to 'pin' when conn.pinUsers loads, while the Server
App pin-users effect calls setSignInMode('pin') for every nonempty response without checking for
password-form interaction. If the response arrives while a cook or server is entering credentials,
the password form is replaced by the PIN picker; the Server App can also replace a selected password
form when the effect re-runs, including after logout.
Code

frontend/src/components/kds/KdsLoginForm.tsx[R18-22]

+  const [signInMode, setSignInMode] = useState<'pin' | 'password' | null>(null);
+  const [selectedPinUser, setSelectedPinUser] = useState<KdsPinUser | null>(null);
+  const [pin, setPin] = useState('');
+
+  const activeSignInMode = pinUsers.length > 0 ? (signInMode ?? 'pin') : 'password';
Relevance

●● Moderate

Real race in new sign-in mode logic, but no close historical precedent either way; PIN-default is
intended behavior per PR intent.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The main POS login guards its PIN default with !email && !password, but KDS has no equivalent
guard when resolving a null mode. In the Server App, the rendered mode falls back to password while
pinUsers is empty, then the asynchronous fetch selects PIN for a nonempty response without
checking for typed credentials or an explicit mode choice; the effect can run again when user
returns to null after logout.

frontend/src/components/kds/KdsLoginForm.tsx[18-22]
frontend/src/app/server-standalone/page.tsx[438-457]
frontend/src/app/auth/login/page.tsx[290-291]
frontend/src/app/server-standalone/page.tsx[202-209]
frontend/src/app/server-standalone/page.tsx[880-888]
frontend/src/app/server-standalone/page.tsx[1298-1299]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
KDS and Server App login screens can switch from a password form to PIN mode when pin-users loads, even after staff have begun entering credentials or selected password mode.

## Fix Focus Areas
- frontend/src/components/kds/KdsLoginForm.tsx[18-22]
- frontend/src/app/server-standalone/page.tsx[438-457]
- frontend/src/app/server-standalone/page.tsx[1298-1299]

## Recommended Fix
Default to PIN only when the email and password fields are empty, as `/auth/login` already does. In KDS, resolve the mode with `signInMode ?? (!conn.loginEmail && !conn.loginPassword ? 'pin' : 'password')`. In the Server App, track whether the user has selected or started using password mode, and call `setSignInMode('pin')` only when the PIN directory first becomes available and neither field has content nor an explicit mode choice has been made. Preserve that choice across subsequent effect runs, refreshes, and logout.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


Grey Divider

Context sources
✅ Linked PRs:
  🌐 PR #39
✅ Compliance rules (platform): 5 rules
✅ Cross-repo context — repo relationships
  Explored: repo: FreeOpenSourcePOS/docs.flopos.com (sha: abe7cff3) — View relationship
✅ REVIEW.md
Review mode: Auto: 🧠 Deep: New PIN auth endpoints on three servers, 56 edit sites, security-sensitive and dense.

Grey Divider

Tip of the day
💡 Did you know, you can pick a display mode instead of tweaking every Display option by hand

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread docs/reference/api.md Resolved
@khaira777
khaira777 force-pushed the fm/flocafe-quick-pin-signin-toggle branch from af9bc0a to c8a4b53 Compare November 8, 2026 21:50
@khaira777 khaira777 changed the title feat(auth): add quick PIN sign-in and mode toggle feat(auth): add quick PIN sign-in to KDS/Server App and mode toggle Nov 8, 2026
@khaira777 khaira777 changed the title feat(auth): add quick PIN sign-in to KDS/Server App and mode toggle feat(auth): add quick PIN sign-in and mode toggle Nov 8, 2026
…ite (Shard 4/4)` and `End-to-End Playwright Tests` (`Playwright E2E (Shard 2/4)` and the cascading timeouts in Shards 1 and 3): 1. **`Core Test Suite (Shard 4/4)` — `test:kds-broadcast-grouping` (`MODULE_NOT_FOUND: '@/lib/login-errors'`)** - **Invariant**: Modules imported by `frontend/src/hooks/useKdsConnection.ts` must resolve under both Next.js (`frontend/tsconfig.json`) and root `ts-node` (`tsconfig.json`, used by `tests/kds-broadcast-grouping.test.ts` without `@/*` path aliases). - **Fix**: Changed `import { parseLoginFailure } from '@/lib/login-errors'` to `'../lib/login-errors'` in `frontend/src/hooks/useKdsConnection.ts`. 2. **`End-to-End Playwright Tests` (`Playwright E2E` Shards 1, 2, 3) — PIN mode toggle & E2E PIN state cleanup** - **Invariants**: - Focusing or typing into the email/password fields on POS (`/auth/login`), KDS (`KdsLoginForm`), or Server App (`/server-standalone`) must lock `signInMode` to `'password'` so an asynchronous `GET /api/auth/pin-users` response never unmounts an active password form mid-interaction. - E2E helpers that log in with email/password while approval PINs are configured in the suite must switch to the password tab (`signin-mode-password`), and E2E suites that configure staff PINs must clear/deactivate those PINs in teardown so subsequent specs in the same shard start with `pinUsers = []`. - **Fixes**: - `frontend/src/app/auth/login/page.tsx`, `frontend/src/components/kds/KdsLoginForm.tsx`, and `frontend/src/app/server-standalone/page.tsx`: unified `signInMode` as `'pin' | 'password' | null` (defaulting to `'pin'` when `pinUsers.length > 0` and no email/password is entered), locked `signInMode` to `'password'` on email/password `onFocus`, and cleared email/password when switching back to `signin-mode-pin`. - `frontend/e2e/ops-admin/helpers.ts` and `frontend/e2e/approval-manager-selection.spec.ts`: awaited `/api/auth/pin-users` on `/auth/login` and clicked `signin-mode-password` when visible before filling `#email` and `#password`. - `frontend/e2e/pin-quick-switch.spec.ts`, `frontend/e2e/approval-manager-selection.spec.ts`, and `frontend/e2e/i18n-batch-5d.spec.ts`: cleared temporary staff PINs (`pin: null`) and deactivated disposable PIN staff (`POST /api/staff/:id/deactivate`) using fresh owner tokens in teardown. 3. **Verification**: - `npm run test:kds-broadcast-grouping` (passed) - `npx ts-node --transpile-only tests/pin-quick-switch.test.ts` (passed) - `npx ts-node --transpile-only tests/auth-ui-deterministic.test.ts` (passed) - `npm run lint && npm run build && npm run build:frontend && npm run docs:check && git diff --check` (passed) - Playwright E2E (`e2e/approval-manager-selection.spec.ts`, `e2e/auth.spec.ts`, `e2e/ops-admin/dashboard-reconciliation.spec.ts`, `e2e/ops-admin/orders-lifecycle.spec.ts`, `e2e/pin-quick-switch.spec.ts` — 19/19 passed)
@khaira777
khaira777 force-pushed the fm/flocafe-quick-pin-signin-toggle branch from 3616756 to 5d7a86d Compare November 8, 2026 22:47
@khaira777
khaira777 merged commit 6e59a1c into main Nov 8, 2026
23 checks passed
@khaira777
khaira777 deleted the fm/flocafe-quick-pin-signin-toggle branch November 8, 2026 22:57
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.

feat(auth): add quick PIN sign-in to KDS/Server App and compact login toggle

1 participant