diff --git a/app/i18n/locales/en.json b/app/i18n/locales/en.json index 9ca7b315c4..651c19d128 100644 --- a/app/i18n/locales/en.json +++ b/app/i18n/locales/en.json @@ -807,5 +807,12 @@ "video-conf-provider-not-configured-body": "A workspace admin needs to enable the conference calls feature first.", "video-conf-provider-not-configured-header": "Conference call not enabled", "you": "you", - "you_were_mentioned": "you were mentioned" + "you_were_mentioned": "you were mentioned", + "User_not_found_or": "User not found or incorrect password", + "Invalid_Email": "Invalid Email", + "Login_has_been_temporarily_blocked_for_this_IP": "Login has been temporarily blocked for this IP", + "Login_has_been_temporarily_blocked_for_this_User": "Login has been temporarily blocked for this User", + "The_maximum_number_of_users_has_been_reached": "The maximum number of users has been reached.", + "App_users_are_not_allowed_to_log_in_directly": "App users are not allowed to log in directly.", + "Before_you_can_login": "Before you can login, your account must be manually activated by an administrator." } \ No newline at end of file diff --git a/app/i18n/locales/pt-BR.json b/app/i18n/locales/pt-BR.json index 0ad610ebdb..acb0263e3b 100644 --- a/app/i18n/locales/pt-BR.json +++ b/app/i18n/locales/pt-BR.json @@ -795,5 +795,13 @@ "video-conf-provider-not-configured-body": "Um administrador do workspace precisa ativar o recurso de chamadas de conferência primeiro.", "video-conf-provider-not-configured-header": "Video conferência não ativada", "you": "você", - "you_were_mentioned": "você foi mencionado" -} \ No newline at end of file + "you_were_mentioned": "você foi mencionado", + "User_not_found_or": "Usuário não encontrado ou senha incorreta", + "Invalid_Email": "E-mail inválido", + "Login_has_been_temporarily_blocked_for_this_IP": "Login foi temporariamente bloqueado para este IP", + "Login_has_been_temporarily_blocked_for_this_User": "Login foi temporariamente bloqueado para este usuário", + "The_maximum_number_of_users_has_been_reached": "O número máximo de usuários foi atingido.", + "App_users_are_not_allowed_to_log_in_directly": "Usuários do aplicativo não estão autorizados a fazer login diretamente.", + "Before_you_can_login": "Antes que você possa fazer login, sua conta precisa ser ativada manualmente por um administrador." +} + diff --git a/app/views/LoginView/UserForm.tsx b/app/views/LoginView/UserForm.tsx index f3f0ae9b4a..e334f6c6f7 100644 --- a/app/views/LoginView/UserForm.tsx +++ b/app/views/LoginView/UserForm.tsx @@ -17,6 +17,7 @@ import sharedStyles from '../Styles'; import UGCRules from '../../containers/UserGeneratedContentRules'; import { useAppSelector } from '../../lib/hooks'; import styles from './styles'; +import { handleLoginErrors } from './handleLoginErrors'; interface ISubmit { user: string; @@ -75,7 +76,7 @@ const UserForm = () => { const user = getValues('user'); navigation.navigate('SendEmailConfirmationView', { user }); } else { - Alert.alert(I18n.t('Oops'), I18n.t('Login_error')); + Alert.alert(I18n.t('Oops'), handleLoginErrors(error?.error)); } } }, [error?.error, failure, getValues, navigation]); diff --git a/app/views/LoginView/handleLoginErrors.ts b/app/views/LoginView/handleLoginErrors.ts new file mode 100644 index 0000000000..37f1b2080c --- /dev/null +++ b/app/views/LoginView/handleLoginErrors.ts @@ -0,0 +1,35 @@ +import i18n from '../../i18n'; + +// https://github.com/RocketChat/Rocket.Chat/blob/cd5cbe2ac60939d4d94a62926b43322be9168ce0/packages/web-ui-registration/src/LoginForm.tsx#L28 +const LOGIN_SUBMIT_ERRORS = { + 'error-user-is-not-activated': { + i18n: 'Before_you_can_login' + }, + 'error-app-user-is-not-allowed-to-login': { + i18n: 'App_users_are_not_allowed_to_log_in_directly' + }, + 'user-not-found': { + i18n: 'User_not_found_or' + }, + 'error-login-blocked-for-ip': { + i18n: 'Login_has_been_temporarily_blocked_for_this_IP' + }, + 'error-login-blocked-for-user': { + i18n: 'Login_has_been_temporarily_blocked_for_this_User' + }, + 'error-license-user-limit-reached': { + i18n: 'The_maximum_number_of_users_has_been_reached' + }, + 'error-invalid-email': { + i18n: 'Invalid_Email' + } +}; + +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); + } + return i18n.t('Login_error'); +};