regression: validate that the login error value is actually a string (#5602)
This commit is contained in:
parent
2f4bde7749
commit
2c0cfa1681
|
@ -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');
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue