Skip to content
Snippets Groups Projects
Commit 440e530a authored by Io Daza-Dillon's avatar Io Daza-Dillon Committed by Io Daza-Dillon
Browse files

Show "Invalid credentials" message for invalid username and invalid password"

Change-Id: I92c28c7e182d78bef21accd842db447f65079a70
parent acebc517
Branches
No related tags found
No related merge requests found
...@@ -44,7 +44,7 @@ describe('authentication', () => { ...@@ -44,7 +44,7 @@ describe('authentication', () => {
cy.get('[data-cy="login-button"]').contains('Log in').click(); cy.get('[data-cy="login-button"]').contains('Log in').click();
cy.get('.MuiAlert-message').contains('Incorrect password'); cy.get('.MuiAlert-message').contains('Invalid credentials');
}); });
it('log in without UI', () => { it('log in without UI', () => {
......
...@@ -81,7 +81,7 @@ type AlertMessageKeys = ...@@ -81,7 +81,7 @@ type AlertMessageKeys =
| 'unknown_error_alert' | 'unknown_error_alert'
| 'username_input_helper_text_empty' | 'username_input_helper_text_empty'
| 'password_input_helper_text_empty' | 'password_input_helper_text_empty'
| 'login_invalid_password' | 'login_invalid_credentials'
| 'registration_success' | 'registration_success'
| ''; | '';
...@@ -111,8 +111,8 @@ const AlertSnackbarProvider = ({ children }: WithChildren) => { ...@@ -111,8 +111,8 @@ const AlertSnackbarProvider = ({ children }: WithChildren) => {
return t('username_input_helper_text_empty'); return t('username_input_helper_text_empty');
case 'password_input_helper_text_empty': case 'password_input_helper_text_empty':
return t('password_input_helper_text_empty'); return t('password_input_helper_text_empty');
case 'login_invalid_password': case 'login_invalid_credentials':
return t('login_invalid_password'); return t('login_invalid_credentials');
case 'registration_success': case 'registration_success':
return t('registration_success'); return t('registration_success');
case 'redirect_admin_setup_complete': case 'redirect_admin_setup_complete':
......
...@@ -80,8 +80,6 @@ ...@@ -80,8 +80,6 @@
"login_form_to_registration_text": "Need an account?", "login_form_to_registration_text": "Need an account?",
"login_form_username_tooltip": "The username you registered with", "login_form_username_tooltip": "The username you registered with",
"login_invalid_credentials": "Invalid credentials", "login_invalid_credentials": "Invalid credentials",
"login_invalid_password": "Incorrect password",
"login_username_not_found": "Username not found",
"logout": "Log out", "logout": "Log out",
"Menu": "Menu", "Menu": "Menu",
"message_call_incoming": "Incoming call - {{duration}}", "message_call_incoming": "Incoming call - {{duration}}",
......
...@@ -80,8 +80,6 @@ ...@@ -80,8 +80,6 @@
"login_form_to_registration_text": "Besoin d'un compte?", "login_form_to_registration_text": "Besoin d'un compte?",
"login_form_username_tooltip": "Le nom d'utilisateur avec lequel vous vous êtes inscrit(e)", "login_form_username_tooltip": "Le nom d'utilisateur avec lequel vous vous êtes inscrit(e)",
"login_invalid_credentials": "Identifiants incorrects", "login_invalid_credentials": "Identifiants incorrects",
"login_invalid_password": "Mot de passe incorrect",
"login_username_not_found": "Nom d'utilisateur introuvable",
"logout": "Se déconnecter", "logout": "Se déconnecter",
"Menu": "Menu", "Menu": "Menu",
"message_call_incoming": "Appel sortant - {{duration}}", "message_call_incoming": "Appel sortant - {{duration}}",
......
...@@ -43,7 +43,7 @@ export const useSetupAdminMutation = () => { ...@@ -43,7 +43,7 @@ export const useSetupAdminMutation = () => {
onError: (e: any) => { onError: (e: any) => {
if (e.response?.status === HttpStatusCode.BadRequest) { if (e.response?.status === HttpStatusCode.BadRequest) {
setAlertContent({ setAlertContent({
messageI18nKey: 'login_invalid_password', messageI18nKey: 'login_invalid_credentials',
severity: 'error', severity: 'error',
alertOpen: true, alertOpen: true,
}); });
...@@ -87,7 +87,7 @@ export const useLoginAdminMutation = () => { ...@@ -87,7 +87,7 @@ export const useLoginAdminMutation = () => {
}); });
} else if (e.response?.status === HttpStatusCode.Unauthorized) { } else if (e.response?.status === HttpStatusCode.Unauthorized) {
setAlertContent({ setAlertContent({
messageI18nKey: 'login_invalid_password', messageI18nKey: 'login_invalid_credentials',
severity: 'error', severity: 'error',
alertOpen: true, alertOpen: true,
}); });
......
...@@ -140,7 +140,7 @@ export const useLoginMutation = () => { ...@@ -140,7 +140,7 @@ export const useLoginMutation = () => {
//TODO: there are two different not found responses that could be returned by the server, use message to differentiate them? //TODO: there are two different not found responses that could be returned by the server, use message to differentiate them?
//continue when the auth flow is clear //continue when the auth flow is clear
} else if (status === HttpStatusCode.Unauthorized) { } else if (status === HttpStatusCode.Unauthorized) {
setAlertContent({ messageI18nKey: 'login_invalid_password', severity: 'error', alertOpen: true }); setAlertContent({ messageI18nKey: 'login_invalid_credentials', severity: 'error', alertOpen: true });
} else { } else {
setAlertContent({ messageI18nKey: 'unknown_error_alert', severity: 'error', alertOpen: true }); setAlertContent({ messageI18nKey: 'unknown_error_alert', severity: 'error', alertOpen: true });
} }
......
...@@ -107,14 +107,14 @@ authRouter.post( ...@@ -107,14 +107,14 @@ authRouter.post(
// Check if the account is stored on this daemon instance // Check if the account is stored on this daemon instance
const accountId = jamid.getAccountIdFromUsername(username); const accountId = jamid.getAccountIdFromUsername(username);
if (accountId === undefined) { if (accountId === undefined) {
res.status(HttpStatusCode.NotFound).send('Username not found'); res.status(HttpStatusCode.Unauthorized).send('Username not found');
return; return;
} }
const hashedPassword = accounts.get(username, isJams); const hashedPassword = accounts.get(username, isJams);
if (hashedPassword === undefined) { if (hashedPassword === undefined) {
res res
.status(HttpStatusCode.NotFound) .status(HttpStatusCode.Unauthorized)
.send('Password not found (the account does not have a password set on the server)'); .send('Password not found (the account does not have a password set on the server)');
return; return;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment