preserve client session after partial load failure
This commit is contained in:
+9
-2
@@ -350,7 +350,10 @@
|
||||
headers: { 'content-type': 'application/json' },
|
||||
body: JSON.stringify({ username, password }),
|
||||
});
|
||||
if (!response.ok) throw new Error('Your username or password may be incorrect.');
|
||||
if (!response.ok) {
|
||||
const failure = (await response.json().catch(() => undefined)) as { message?: string; code?: string } | undefined;
|
||||
throw new Error(failure?.message || failure?.code || 'The server could not process the login.');
|
||||
}
|
||||
const result: { session_token: string; must_replace_credentials: boolean } = await response.json();
|
||||
sessionToken = result.session_token;
|
||||
authenticated = true;
|
||||
@@ -359,7 +362,11 @@
|
||||
authError = 'Login succeeded, but the session could not be stored in the Linux keyring.';
|
||||
});
|
||||
connectionState = 'CONNECTED';
|
||||
await loadAuthenticatedData();
|
||||
try {
|
||||
await loadAuthenticatedData();
|
||||
} catch {
|
||||
authError = 'Login succeeded, but some dashboard data could not be loaded.';
|
||||
}
|
||||
if (!mustReplaceCredentials) password = '';
|
||||
if (mustReplaceCredentials) newUsername = username;
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user