mirror of
https://github.com/inventree/InvenTree.git
synced 2025-10-24 18:07:38 +00:00
[UI] Adjust login error messages (#10556)
* Adjust config template - Don't hard-code cookie mode into template - Revert to the "default" values (which are the same) * [ui] better feedback on login error - Show error code, at least * Revert removed code * Adjust playwright tests
This commit is contained in:
@@ -106,14 +106,37 @@ export async function doBasicLogin(
|
||||
}
|
||||
})
|
||||
.catch(async (err) => {
|
||||
if (err?.response?.status == 401) {
|
||||
await handlePossibleMFAError(err);
|
||||
} else if (err?.response?.status == 409) {
|
||||
notifications.hide('auth-login-error');
|
||||
|
||||
if (err?.response?.status) {
|
||||
switch (err.response.status) {
|
||||
case 401:
|
||||
await handlePossibleMFAError(err);
|
||||
break;
|
||||
case 409:
|
||||
notifications.show({
|
||||
title: t`Already logged in`,
|
||||
message: t`There is a conflicting session on the server for this browser. Please logout of that first.`,
|
||||
color: 'red',
|
||||
id: 'auth-login-error',
|
||||
autoClose: false
|
||||
});
|
||||
break;
|
||||
default:
|
||||
notifications.show({
|
||||
title: `${t`Login failed`} (${err.response.status})`,
|
||||
message: t`Check your input and try again.`,
|
||||
id: 'auth-login-error',
|
||||
color: 'red'
|
||||
});
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
notifications.show({
|
||||
title: t`Already logged in`,
|
||||
message: t`There is a conflicting session on the server for this browser. Please logout of that first.`,
|
||||
title: t`Login failed`,
|
||||
message: t`No response from server.`,
|
||||
color: 'red',
|
||||
autoClose: false
|
||||
id: 'login-error'
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -9,8 +9,8 @@ import { doLogin } from './login.js';
|
||||
test('Login - Failures', async ({ page }) => {
|
||||
const loginWithError = async () => {
|
||||
await page.getByRole('button', { name: 'Log In' }).click();
|
||||
await page.getByText('Login failed').waitFor();
|
||||
await page.getByText('Check your input and try again').waitFor();
|
||||
await page.getByText('Login failed', { exact: true }).waitFor();
|
||||
await page.getByText('Check your input and try again').first().waitFor();
|
||||
await page.locator('#login').getByRole('button').click();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user