regression: validate that the login error value is actually a string (#5602)

This commit is contained in:
Gleidson Daniel Silva 2024-03-06 10:04:12 -03:00 committed by GitHub
parent 2f4bde7749
commit 2c0cfa1681
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 4 deletions

View File

@ -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');
};