Skip to content

Commit f3ee2dc

Browse files
dnlsilvaGleidsonDanieldiegolmello
authored
feat: improve login error message (#5594)
* feat: improve login error message * action: organized translations * Update app/i18n/locales/en.json Co-authored-by: Diego Mello <[email protected]> * Update app/i18n/locales/en.json Co-authored-by: Diego Mello <[email protected]> * wip * action: organized translations --------- Co-authored-by: GleidsonDaniel <[email protected]> Co-authored-by: Diego Mello <[email protected]>
1 parent f56f19a commit f3ee2dc

File tree

4 files changed

+51
-1
lines changed

4 files changed

+51
-1
lines changed

app/i18n/locales/en.json

+7
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"Allow_Reactions": "Allow reactions",
2727
"Also_send_thread_message_to_channel_behavior": "Also send thread message to channel",
2828
"Announcement": "Announcement",
29+
"App_users_are_not_allowed_to_log_in_directly": "App users are not allowed to log in directly.",
2930
"Apply_Your_Certificate": "Apply your certificate",
3031
"Are_you_sure_question_mark": "Are you sure?",
3132
"Are_you_sure_you_want_to_delete_your_account": "Are you sure you want to delete your account?",
@@ -39,6 +40,7 @@
3940
"Avatar_changed_successfully": "Avatar changed successfully!",
4041
"Avatars": "Avatars",
4142
"Away": "Away",
43+
"Before_you_can_login": "Before you can login, your account must be manually activated by an administrator.",
4244
"Bio": "Bio",
4345
"Black": "Black",
4446
"Block": "Block",
@@ -256,6 +258,7 @@
256258
"Incoming_call_from": "Incoming call from",
257259
"Inline_code": "Inline code",
258260
"Insert_Join_Code": "Insert join code",
261+
"Invalid_Email": "Invalid email",
259262
"Invalid_or_expired_invite_token": "Invalid or expired invite token",
260263
"Invalid_server_version": "The workspace you're trying to connect is using a version that's not supported by the app anymore: {{currentVersion}}.\n\nWe require version {{minVersion}}",
261264
"Invisible": "Invisible",
@@ -312,6 +315,8 @@
312315
"Logging_out": "Logging out.",
313316
"Login": "Login",
314317
"Login_error": "Your credentials were rejected! Please try again.",
318+
"Login_has_been_temporarily_blocked_for_this_IP": "Login has been temporarily blocked for this IP",
319+
"Login_has_been_temporarily_blocked_for_this_User": "Login has been temporarily blocked for this user",
315320
"Logout": "Logout",
316321
"Logout_failed": "Logout failed!",
317322
"Logout_from_other_logged_in_locations": "Logout from other logged in locations",
@@ -600,6 +605,7 @@
600605
"Team_not_found": "Team not found",
601606
"Teams": "Teams",
602607
"Terms_of_Service": " Terms of service ",
608+
"The_maximum_number_of_users_has_been_reached": "The maximum number of users has been reached.",
603609
"The_room_does_not_exist": "The room does not exist or you may not have access permission",
604610
"The_user_will_be_able_to_type_in_roomName": "The user will be able to type in {{roomName}}",
605611
"The_user_will_be_removed_from_s": "The user will be removed from {{s}}",
@@ -660,6 +666,7 @@
660666
"User_joined_the_conversation": "joined the conversation",
661667
"User_joined_the_team": "joined this team",
662668
"User_left_this_channel": "left the channel",
669+
"User_not_found_or": "User not found or incorrect password",
663670
"User_sent_an_attachment": "{{user}} sent an attachment",
664671
"Username": "Username",
665672
"Username_or_email": "Username or email",

app/i18n/locales/pt-BR.json

+7
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"Allow_Reactions": "Permitir reagir",
2626
"Also_send_thread_message_to_channel_behavior": "Também enviar mensagem do tópico para o canal",
2727
"Announcement": "Anúncio",
28+
"App_users_are_not_allowed_to_log_in_directly": "Usuários do aplicativo não estão autorizados a fazer login diretamente.",
2829
"Apply_Your_Certificate": "Aplicar certificado",
2930
"Are_you_sure_question_mark": "Você tem certeza?",
3031
"Are_you_sure_you_want_to_delete_your_account": "Tem certeza de que deseja excluir sua conta?",
@@ -38,6 +39,7 @@
3839
"Avatar_changed_successfully": "Avatar alterado com sucesso!",
3940
"Avatars": "Avatars",
4041
"Away": "Ausente",
42+
"Before_you_can_login": "Antes que você possa fazer login, sua conta precisa ser ativada manualmente por um administrador.",
4143
"Bio": "Biografia",
4244
"Black": "Preto",
4345
"Block": "Bloquear",
@@ -252,6 +254,7 @@
252254
"In_app_message_notifications": "Notificações de mensagens in-app",
253255
"Incoming_call_from": "Chamada recebida de",
254256
"Insert_Join_Code": "Insira o código para entrar na sala",
257+
"Invalid_Email": "E-mail inválido",
255258
"Invalid_or_expired_invite_token": "Token de convite inválido ou vencido",
256259
"Invalid_server_version": "O servidor que você está conectando não é suportado mais por esta versão do aplicativo: {{currentVersion}}.\n\nEsta versão do aplicativo requer a versão {{minVersion}} da workspace para funcionar corretamente.",
257260
"Invisible": "Invisível",
@@ -307,6 +310,8 @@
307310
"Logging_out": "Saindo.",
308311
"Login": "Entrar",
309312
"Login_error": "Suas credenciais foram rejeitadas. Tente novamente por favor!",
313+
"Login_has_been_temporarily_blocked_for_this_IP": "Login foi temporariamente bloqueado para este IP",
314+
"Login_has_been_temporarily_blocked_for_this_User": "Login foi temporariamente bloqueado para este usuário",
310315
"Logout": "Sair",
311316
"Logout_failed": "Falha ao desconectar!",
312317
"Logout_from_other_logged_in_locations": "Sair de outros locais logados",
@@ -588,6 +593,7 @@
588593
"Team_not_found": "Time não encontrado",
589594
"Teams": "Times",
590595
"Terms_of_Service": " Termos de serviço ",
596+
"The_maximum_number_of_users_has_been_reached": "O número máximo de usuários foi atingido.",
591597
"The_room_does_not_exist": "A sala não existe ou você pode não ter permissão de acesso",
592598
"The_user_will_be_able_to_type_in_roomName": "O usuário poderá digitar em {{roomName}}",
593599
"The_user_will_be_removed_from_s": "O usuário será removido de {{s}}",
@@ -648,6 +654,7 @@
648654
"User_joined_the_conversation": "entrou na conversa",
649655
"User_joined_the_team": "entrou no time",
650656
"User_left_this_channel": "saiu da conversa",
657+
"User_not_found_or": "Usuário não encontrado ou senha incorreta",
651658
"User_sent_an_attachment": "{{user}} enviou um anexo",
652659
"Username": "Usuário",
653660
"Username_or_email": "Usuário ou email",

app/views/LoginView/UserForm.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import sharedStyles from '../Styles';
1717
import UGCRules from '../../containers/UserGeneratedContentRules';
1818
import { useAppSelector } from '../../lib/hooks';
1919
import styles from './styles';
20+
import { handleLoginErrors } from './handleLoginErrors';
2021

2122
interface ISubmit {
2223
user: string;
@@ -75,7 +76,7 @@ const UserForm = () => {
7576
const user = getValues('user');
7677
navigation.navigate('SendEmailConfirmationView', { user });
7778
} else {
78-
Alert.alert(I18n.t('Oops'), I18n.t('Login_error'));
79+
Alert.alert(I18n.t('Oops'), handleLoginErrors(error?.error));
7980
}
8081
}
8182
}, [error?.error, failure, getValues, navigation]);
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import i18n from '../../i18n';
2+
3+
// https://github.com/RocketChat/Rocket.Chat/blob/cd5cbe2ac60939d4d94a62926b43322be9168ce0/packages/web-ui-registration/src/LoginForm.tsx#L28
4+
const LOGIN_SUBMIT_ERRORS = {
5+
'error-user-is-not-activated': {
6+
i18n: 'Before_you_can_login'
7+
},
8+
'error-app-user-is-not-allowed-to-login': {
9+
i18n: 'App_users_are_not_allowed_to_log_in_directly'
10+
},
11+
'user-not-found': {
12+
i18n: 'User_not_found_or'
13+
},
14+
'error-login-blocked-for-ip': {
15+
i18n: 'Login_has_been_temporarily_blocked_for_this_IP'
16+
},
17+
'error-login-blocked-for-user': {
18+
i18n: 'Login_has_been_temporarily_blocked_for_this_User'
19+
},
20+
'error-license-user-limit-reached': {
21+
i18n: 'The_maximum_number_of_users_has_been_reached'
22+
},
23+
'error-invalid-email': {
24+
i18n: 'Invalid_Email'
25+
}
26+
};
27+
28+
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);
33+
}
34+
return i18n.t('Login_error');
35+
};

0 commit comments

Comments
 (0)