fix(tracker-web): include productId in login (LoginSchema requires it)
The login form posted {email,password} but platform-service LoginSchema
requires productId, so real logins returned 400 (only the mocked e2e passed).
Send the selected product (tracker_selected_product) or the default PRODUCT_ID.
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
2253f888c7
commit
939c7b4621
@ -1,6 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import { createContext, useContext, useState, useEffect, useCallback, type ReactNode } from 'react';
|
||||
import { PRODUCT_ID } from './product-constants';
|
||||
|
||||
interface User {
|
||||
id: string;
|
||||
@ -54,10 +55,15 @@ export function AuthProvider({ children }: { children: ReactNode }) {
|
||||
}, []);
|
||||
|
||||
const login = useCallback(async (email: string, password: string) => {
|
||||
// platform-service LoginSchema requires productId — use the selected product
|
||||
// (set by the product switcher) or fall back to the default product.
|
||||
const productId =
|
||||
(typeof window !== 'undefined' && localStorage.getItem('tracker_selected_product')) ||
|
||||
PRODUCT_ID;
|
||||
const res = await fetch('/api/auth/login', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ email, password }),
|
||||
body: JSON.stringify({ email, password, productId }),
|
||||
});
|
||||
if (!res.ok) {
|
||||
const body = await res.json().catch(() => ({}));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user