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 => {
|
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;
|
if (typeof error === 'string') {
|
||||||
const e = errorKey ? LOGIN_SUBMIT_ERRORS[errorKey].i18n : 'Login_error';
|
const errorKey = Object.keys(LOGIN_SUBMIT_ERRORS).find(key => error?.includes(key)) as keyof typeof LOGIN_SUBMIT_ERRORS;
|
||||||
if (i18n.isTranslated(e)) {
|
const e = errorKey ? LOGIN_SUBMIT_ERRORS[errorKey]?.i18n : 'Login_error';
|
||||||
return i18n.t(e);
|
if (i18n.isTranslated(e)) {
|
||||||
|
return i18n.t(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return i18n.t('Login_error');
|
return i18n.t('Login_error');
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue