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) }),
|
||||
|
||||
login: (email: string, password: string) =>
|
||||
req<{ user_id: number; email: string; api_key_prefix: string }>('/api/login', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ email, password }),
|
||||
}),
|
||||
req<{ user_id: number; email: string; api_key: string; mcp_connection: { url: string; header: string } }>(
|
||||
'/api/login',
|
||||
{ method: 'POST', body: JSON.stringify({ email, password }) },
|
||||
),
|
||||
|
||||
me: (apiKey: string) =>
|
||||
req<MeResult>('/api/me', { headers: authHeader(apiKey) }),
|
||||
|
||||
@ -13,15 +13,8 @@ export default function Login() {
|
||||
setError('');
|
||||
setLoading(true);
|
||||
try {
|
||||
const savedKey = session.getKey();
|
||||
if (!savedKey) {
|
||||
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);
|
||||
const result = await api.login(form.email, form.password);
|
||||
session.save(result.api_key, result.email);
|
||||
navigate('/dashboard');
|
||||
} catch (err: unknown) {
|
||||
setError(err instanceof Error ? err.message : 'Login failed');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user