Skip to content

Commit 2c0cfa1

Browse files
authored
regression: validate that the login error value is actually a string (#5602)
1 parent 2f4bde7 commit 2c0cfa1

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

app/views/LoginView/handleLoginErrors.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ const LOGIN_SUBMIT_ERRORS = {
2626
};
2727

2828
export const handleLoginErrors = (error: keyof typeof LOGIN_SUBMIT_ERRORS): string => {
29-
const errorKey = Object.keys(LOGIN_SUBMIT_ERRORS).find(key => error.includes(key)) as keyof typeof LOGIN_SUBMIT_ERRORS;
30-
const e = errorKey ? LOGIN_SUBMIT_ERRORS[errorKey].i18n : 'Login_error';
31-
if (i18n.isTranslated(e)) {
32-
return i18n.t(e);
29+
if (typeof error === 'string') {
30+
const errorKey = Object.keys(LOGIN_SUBMIT_ERRORS).find(key => error?.includes(key)) as keyof typeof LOGIN_SUBMIT_ERRORS;
31+
const e = errorKey ? LOGIN_SUBMIT_ERRORS[errorKey]?.i18n : 'Login_error';
32+
if (i18n.isTranslated(e)) {
33+
return i18n.t(e);
34+
}
3335
}
3436
return i18n.t('Login_error');
3537
};

0 commit comments

Comments
 (0)