From 270ec794509c5872df735af691bca13e85a6fe02 Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Mon, 17 Feb 2020 16:24:27 -0300 Subject: [PATCH] [IMPROVEMENT] Alert verify email when enabled (#1725) --- app/constants/settings.js | 3 +++ app/i18n/locales/en.js | 2 ++ app/i18n/locales/pt-BR.js | 2 ++ app/views/RegisterView.js | 14 +++++++++++--- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/app/constants/settings.js b/app/constants/settings.js index 74c6234f..f812c5c6 100644 --- a/app/constants/settings.js +++ b/app/constants/settings.js @@ -5,6 +5,9 @@ export default { Accounts_EmailOrUsernamePlaceholder: { type: 'valueAsString' }, + Accounts_EmailVerification: { + type: 'valueAsBoolean' + }, Accounts_NamePlaceholder: { type: 'valueAsString' }, diff --git a/app/i18n/locales/en.js b/app/i18n/locales/en.js index f48b0f3b..d5bdfcf8 100644 --- a/app/i18n/locales/en.js +++ b/app/i18n/locales/en.js @@ -450,6 +450,8 @@ export default { Username: 'Username', Username_or_email: 'Username or email', Validating: 'Validating', + Verify_email_title: 'Registration Succeeded!', + Verify_email_desc: 'We have sent you an email to confirm your registration. If you do not receive an email shortly, please come back and try again.', Video_call: 'Video call', View_Original: 'View Original', Voice_call: 'Voice call', diff --git a/app/i18n/locales/pt-BR.js b/app/i18n/locales/pt-BR.js index 3a789fa9..c1d7a95d 100644 --- a/app/i18n/locales/pt-BR.js +++ b/app/i18n/locales/pt-BR.js @@ -404,6 +404,8 @@ export default { Username_is_empty: 'Usuário está vazio', Username: 'Usuário', Username_or_email: 'Usuário ou email', + Verify_email_title: 'Registrado com sucesso!', + Verify_email_desc: 'Nós lhe enviamos um e-mail para confirmar o seu registro. Se você não receber um e-mail em breve, por favor retorne e tente novamente.', Video_call: 'Chamada de vídeo', Voice_call: 'Chamada de voz', Websocket_disabled: 'Websocket está desativado para esse servidor.\n{{contact}}', diff --git a/app/views/RegisterView.js b/app/views/RegisterView.js index 12e79b63..964b2e78 100644 --- a/app/views/RegisterView.js +++ b/app/views/RegisterView.js @@ -42,6 +42,7 @@ class RegisterView extends React.Component { loginRequest: PropTypes.func, Site_Name: PropTypes.string, Accounts_CustomFields: PropTypes.string, + Accounts_EmailVerification: PropTypes.bool, theme: PropTypes.string } @@ -119,13 +120,19 @@ class RegisterView extends React.Component { const { name, email, password, username, customFields } = this.state; - const { loginRequest } = this.props; + const { loginRequest, Accounts_EmailVerification, navigation } = this.props; try { await RocketChat.register({ name, email, pass: password, username, ...customFields }); - await loginRequest({ user: email, password }); + + if (Accounts_EmailVerification) { + await navigation.goBack(); + Alert.alert(I18n.t('Verify_email_title'), I18n.t('Verify_email_desc')); + } else { + await loginRequest({ user: email, password }); + } } catch (e) { Alert.alert(I18n.t('Oops'), e.data.error); } @@ -267,7 +274,8 @@ class RegisterView extends React.Component { } const mapStateToProps = state => ({ - Accounts_CustomFields: state.settings.Accounts_CustomFields + Accounts_CustomFields: state.settings.Accounts_CustomFields, + Accounts_EmailVerification: state.settings.Accounts_EmailVerification }); const mapDispatchToProps = dispatch => ({