Fix login requiring a pre-existing saved key to work at all
Login previously bailed out with "No API key found" unless a key from a prior signup already happened to be sitting in this browser's localStorage — meaning login was completely broken on any new device, browser, or after clearing storage, regardless of a correct password. /api/login now issues a real usable key on every successful login; the frontend just saves it. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
27cefb2f60
commit
3f33e6a98b
@ -174,10 +174,10 @@ export const api = {
|
|||||||
req<SignupResult>('/api/signup', { method: 'POST', body: JSON.stringify(body) }),
|
req<SignupResult>('/api/signup', { method: 'POST', body: JSON.stringify(body) }),
|
||||||
|
|
||||||
login: (email: string, password: string) =>
|
login: (email: string, password: string) =>
|
||||||
req<{ user_id: number; email: string; api_key_prefix: string }>('/api/login', {
|
req<{ user_id: number; email: string; api_key: string; mcp_connection: { url: string; header: string } }>(
|
||||||
method: 'POST',
|
'/api/login',
|
||||||
body: JSON.stringify({ email, password }),
|
{ method: 'POST', body: JSON.stringify({ email, password }) },
|
||||||
}),
|
),
|
||||||
|
|
||||||
me: (apiKey: string) =>
|
me: (apiKey: string) =>
|
||||||
req<MeResult>('/api/me', { headers: authHeader(apiKey) }),
|
req<MeResult>('/api/me', { headers: authHeader(apiKey) }),
|
||||||
|
|||||||
@ -13,15 +13,8 @@ export default function Login() {
|
|||||||
setError('');
|
setError('');
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
const savedKey = session.getKey();
|
const result = await api.login(form.email, form.password);
|
||||||
if (!savedKey) {
|
session.save(result.api_key, result.email);
|
||||||
setError('No API key found. Please use your API key directly or re-generate it from a previous signup.');
|
|
||||||
setLoading(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Verify credentials via /api/login then confirm key works
|
|
||||||
await api.login(form.email, form.password);
|
|
||||||
session.save(savedKey, form.email);
|
|
||||||
navigate('/dashboard');
|
navigate('/dashboard');
|
||||||
} catch (err: unknown) {
|
} catch (err: unknown) {
|
||||||
setError(err instanceof Error ? err.message : 'Login failed');
|
setError(err instanceof Error ? err.message : 'Login failed');
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user