From 96e5b0b2043cfb86ab28c596c00b39b5007718ab Mon Sep 17 00:00:00 2001 From: GleidsonDaniel Date: Mon, 4 Mar 2024 09:14:13 -0300 Subject: [PATCH] regression: validate that the login error value is actually a string --- app/views/LoginView/handleLoginErrors.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/views/LoginView/handleLoginErrors.ts b/app/views/LoginView/handleLoginErrors.ts index 37f1b2080c..5e352b2864 100644 --- a/app/views/LoginView/handleLoginErrors.ts +++ b/app/views/LoginView/handleLoginErrors.ts @@ -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'); };