Bug 1: JWT field name mismatch breaks registration flow
Location: frontend/src/store/auth.ts:47-55
The backend POST /auth/register returns access_token, but the frontend register function reads data.token (which is undefined).
Backend (main/routes/auth.ts:455-456):
res.json({ access_token: token, ... });
Frontend (frontend/src/store/auth.ts:47-55):
register: async (registerData: RegisterData) => {
const { data } = await api.post('/auth/register', registerData);
localStorage.setItem('token', data.token); // ❌ should be data.access_token
set({
user: data.user,
token: data.token, // ❌ undefined
tenants: [data.tenant],
});
},
Impact: After registration, the token stored is undefined. Subsequent API calls fail with 401. User appears logged in but sessions are broken until re-login.
Fix: Change data.token to data.access_token (matching the login function on line 39 and the backend response).
Bug 2: setAddingItems(true) never reset in TableCheckoutModal
Location: frontend/src/components/pos/TableCheckoutModal.tsx:71-75
const handleAddCartToOrder = async () => {
if (!order || !onAddCartToOrder) return;
setAddingItems(true); // ← set to true
onAddCartToOrder(table, order); // ← never reset
};
Compare with handleCheckout which has proper try/finally:
const handleCheckout = async () => {
setGenerating(true);
try { ... } finally { setGenerating(false); }
};
Impact: Button can get stuck in "Adding..." state if the callback throws or the modal stays open. Low severity but inconsistent with the rest of the component.
Fix: Add try/finally around the callback, or accept that the parent handles state and reset in a finally block.
Bug 1: JWT field name mismatch breaks registration flow
Location:
frontend/src/store/auth.ts:47-55The backend
POST /auth/registerreturnsaccess_token, but the frontendregisterfunction readsdata.token(which isundefined).Backend (
main/routes/auth.ts:455-456):Frontend (
frontend/src/store/auth.ts:47-55):Impact: After registration, the token stored is
undefined. Subsequent API calls fail with 401. User appears logged in but sessions are broken until re-login.Fix: Change
data.tokentodata.access_token(matching the login function on line 39 and the backend response).Bug 2:
setAddingItems(true)never reset in TableCheckoutModalLocation:
frontend/src/components/pos/TableCheckoutModal.tsx:71-75Compare with
handleCheckoutwhich has propertry/finally:Impact: Button can get stuck in "Adding..." state if the callback throws or the modal stays open. Low severity but inconsistent with the rest of the component.
Fix: Add
try/finallyaround the callback, or accept that the parent handles state and reset in afinallyblock.