From ff9e20ed7d3837240f23a0e61da64a886e6ef659 Mon Sep 17 00:00:00 2001 From: Wilian Gabriel <63816070+wiliansilvazup@users.noreply.github.com> Date: Wed, 11 Nov 2020 13:56:39 -0300 Subject: [PATCH] =?UTF-8?q?Adjusting=20to=20view=20field=20of=20email=20to?= =?UTF-8?q?=20app=20admin=20when=20create=20new=20organiz=E2=80=A6=20(#127?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Adjusting to view field of email to app admin when create new organization (#125) * Adding validation for user response when ask if run in current directory (#124) Co-authored-by: Lucas Bruno <69604366+lucasbrunozup@users.noreply.github.com> --- horusec-cli/cmd/horusec/start/start.go | 16 +++++++++++++--- .../src/pages/Internal/Company/Add/index.tsx | 8 +++----- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/horusec-cli/cmd/horusec/start/start.go b/horusec-cli/cmd/horusec/start/start.go index f79e7370d..a0070971a 100644 --- a/horusec-cli/cmd/horusec/start/start.go +++ b/horusec-cli/cmd/horusec/start/start.go @@ -132,9 +132,19 @@ func (s *Start) askIfRunInDirectorySelected(shouldAsk bool) error { if err != nil { return err } - if !strings.EqualFold(response, "y") { - return errors.New("{HORUSEC_CLI} Operation was canceled by user") - } + return s.validateReplyOfAsk(response) + } + return nil +} + +func (s *Start) validateReplyOfAsk(response string) error { + if !strings.EqualFold(response, "y") && !strings.EqualFold(response, "n") { + logger.LogErrorWithLevel("Your response was: '"+response+"' Please type Y or N", + errors.New("reply invalid"), logger.ErrorLevel) + return s.askIfRunInDirectorySelected(true) + } + if strings.EqualFold(response, "n") { + return errors.New("{HORUSEC_CLI} Operation was canceled by user") } return nil } diff --git a/horusec-manager/src/pages/Internal/Company/Add/index.tsx b/horusec-manager/src/pages/Internal/Company/Add/index.tsx index e2d1a5401..e08e5516b 100644 --- a/horusec-manager/src/pages/Internal/Company/Add/index.tsx +++ b/horusec-manager/src/pages/Internal/Company/Add/index.tsx @@ -24,15 +24,13 @@ import { useHistory } from 'react-router-dom'; import { CompanyContext } from 'contexts/Company'; import { getCurrentConfig } from 'helpers/localStorage/horusecConfig'; import { authTypes } from 'helpers/enums/authTypes'; -import { - isApplicationAdmin, - getCurrentUser, -} from 'helpers/localStorage/currentUser'; +import { getCurrentUser } from 'helpers/localStorage/currentUser'; function AddCompany() { const { t } = useTranslation(); const history = useHistory(); const currentUser = getCurrentUser(); + const { applicationAdminEnable } = getCurrentConfig(); const [companyName, setCompanyName] = useState({ isValid: false, @@ -84,7 +82,7 @@ function AddCompany() { invalidMessage={t('COMPANY_SCREEN.INVALID_ORGANIZATION_NAME')} /> - {isApplicationAdmin() ? ( + {applicationAdminEnable ? ( {t('COMPANY_SCREEN.ADMIN_EMAIL')}