Skip to content

Commit

Permalink
regression: validate that the login error value is actually a string (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
GleidsonDaniel committed Mar 6, 2024
1 parent 2f4bde7 commit 2c0cfa1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/views/LoginView/handleLoginErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ const LOGIN_SUBMIT_ERRORS = {
};

export const handleLoginErrors = (error: keyof typeof LOGIN_SUBMIT_ERRORS): string => {
const errorKey = Object.keys(LOGIN_SUBMIT_ERRORS).find(key => error.includes(key)) as keyof typeof LOGIN_SUBMIT_ERRORS;
const e = errorKey ? LOGIN_SUBMIT_ERRORS[errorKey].i18n : 'Login_error';
if (i18n.isTranslated(e)) {
return i18n.t(e);
if (typeof error === 'string') {
const errorKey = Object.keys(LOGIN_SUBMIT_ERRORS).find(key => error?.includes(key)) as keyof typeof LOGIN_SUBMIT_ERRORS;
const e = errorKey ? LOGIN_SUBMIT_ERRORS[errorKey]?.i18n : 'Login_error';
if (i18n.isTranslated(e)) {
return i18n.t(e);
}
}
return i18n.t('Login_error');
};

0 comments on commit 2c0cfa1

Please sign in to comment.