From 010aad6308f87e659971f80f985dfe96855772f2 Mon Sep 17 00:00:00 2001 From: Harshil Sharma <18575143+harshilsharma63@users.noreply.github.com> Date: Thu, 9 Apr 2026 10:21:08 +0530 Subject: [PATCH] Fixed a bug where signup link showed up when signup was disabled (#35769) * Fixed a bug where signup link showed up when signup was disabled * Removed unused component * fixed test name * CI * fixed a test * fixed a commit --------- Co-authored-by: Mattermost Build --- .../auth_sso/authentication_4_spec.ts | 8 +-- .../login_close_server_spec.js | 5 +- .../access_problem/access_problem.scss | 40 --------------- .../src/components/access_problem/index.tsx | 51 ------------------- .../src/components/login/login.test.tsx | 19 +++++++ .../channels/src/components/login/login.tsx | 15 ++---- webapp/channels/src/components/root/root.tsx | 5 -- webapp/channels/src/i18n/en.json | 2 - 8 files changed, 28 insertions(+), 117 deletions(-) delete mode 100644 webapp/channels/src/components/access_problem/access_problem.scss delete mode 100644 webapp/channels/src/components/access_problem/index.tsx diff --git a/e2e-tests/cypress/tests/integration/channels/auth_sso/authentication_4_spec.ts b/e2e-tests/cypress/tests/integration/channels/auth_sso/authentication_4_spec.ts index 64234aecb66..24d8a049b89 100644 --- a/e2e-tests/cypress/tests/integration/channels/auth_sso/authentication_4_spec.ts +++ b/e2e-tests/cypress/tests/integration/channels/auth_sso/authentication_4_spec.ts @@ -209,12 +209,8 @@ describe('Authentication', () => { // # Go to front page cy.visit('/login'); - // * Assert that create account button is visible - cy.findByText('Don\'t have an account?', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').click(); - - // * Verify redirection to access problem page since account creation is disabled - cy.url().should('include', '/access_problem'); - cy.findByText('Contact your workspace admin'); + // * Assert that create account button is not visible + cy.findByText('Don\'t have an account?', {timeout: TIMEOUTS.ONE_MIN}).should('not.exist'); // # Go to sign up with email page cy.visit('/signup_user_complete'); diff --git a/e2e-tests/cypress/tests/integration/channels/signin_authentication/login_close_server_spec.js b/e2e-tests/cypress/tests/integration/channels/signin_authentication/login_close_server_spec.js index db4a64eebb9..83011c91130 100644 --- a/e2e-tests/cypress/tests/integration/channels/signin_authentication/login_close_server_spec.js +++ b/e2e-tests/cypress/tests/integration/channels/signin_authentication/login_close_server_spec.js @@ -36,8 +36,7 @@ describe('Login page with close server', () => { // Restore backed up settings cy.apiAdminLogin().apiUpdateConfig(oldSettings); }); - it('MM-47222 Should verify access problem page can be reached', () => { - cy.findByText('Don\'t have an account?').should('be.visible').click(); - cy.findByText('Contact your workspace admin').should('be.visible'); + it('MM-47222 Should verify signup link not visible', () => { + cy.findByText('Don\'t have an account?').should('not.exist'); }); }); diff --git a/webapp/channels/src/components/access_problem/access_problem.scss b/webapp/channels/src/components/access_problem/access_problem.scss deleted file mode 100644 index 7386478f691..00000000000 --- a/webapp/channels/src/components/access_problem/access_problem.scss +++ /dev/null @@ -1,40 +0,0 @@ -.header-footer-route .header-footer-route-container { - display: flex; - justify-content: space-between; -} - -.AccessProblem { - &__body { - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - } - - &__title { - display: flex; - align-items: center; - margin: 32px 0 16px 0; - color: var(--portal-denim); - font-family: 'Metropolis'; - font-size: 22px; - font-style: normal; - font-weight: 600; - line-height: 28px; - text-align: center; - } - - &__description { - display: flex; - max-width: 640px; - align-items: center; - padding: 0 40px; - color: var(--portal-denim); - font-family: 'Open Sans'; - font-size: 14px; - font-style: normal; - font-weight: 400; - line-height: 20px; - text-align: center; - } -} diff --git a/webapp/channels/src/components/access_problem/index.tsx b/webapp/channels/src/components/access_problem/index.tsx deleted file mode 100644 index 05429c7fbe0..00000000000 --- a/webapp/channels/src/components/access_problem/index.tsx +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. -// See LICENSE.txt for license information. - -import React, {useCallback, useEffect} from 'react'; -import {useIntl} from 'react-intl'; -import {useHistory} from 'react-router-dom'; - -import AccessProblemSVG from 'components/common/svg_images_components/access_problem_svg'; -import type {CustomizeHeaderType} from 'components/header_footer_route/header_footer_route'; - -import './access_problem.scss'; - -type AccessProblemProps = { - onCustomizeHeader?: CustomizeHeaderType; -} - -const AccessProblem = ({ - onCustomizeHeader, -}: AccessProblemProps) => { - const {formatMessage} = useIntl(); - const history = useHistory(); - - const handleHeaderBackButtonOnClick = useCallback(() => { - history.goBack(); - }, [history]); - - useEffect(() => { - if (onCustomizeHeader) { - onCustomizeHeader({ - onBackButtonClick: handleHeaderBackButtonOnClick, - }); - } - }, [onCustomizeHeader, handleHeaderBackButtonOnClick]); - - return ( -
- -
- {formatMessage({id: 'login.contact_admin.title', defaultMessage: 'Contact your workspace admin'})} -
-
- {formatMessage({id: 'login.contact_admin.detail', defaultMessage: "To access your team's workspace, contact your workspace admin. If you've been invited already, check your email inbox for a Mattermost workspace invite."})} -
-
- ); -}; - -export default AccessProblem; diff --git a/webapp/channels/src/components/login/login.test.tsx b/webapp/channels/src/components/login/login.test.tsx index 2f901fb0890..fc87d76a110 100644 --- a/webapp/channels/src/components/login/login.test.tsx +++ b/webapp/channels/src/components/login/login.test.tsx @@ -408,6 +408,25 @@ describe('components/login/Login', () => { expect(history.push).toHaveBeenCalledWith(redirectPath); }); + it('should not show dont have an account when open server is disabled', () => { + const state = mergeObjects(baseState, { + entities: { + general: { + config: { + EnableOpenServer: 'false', + }, + }, + }, + }); + + renderWithContext( + , + state, + ); + + expect(screen.queryByText('Don\'t have an account')).not.toBeInTheDocument(); + }); + describe('EnableGuestMagicLink', () => { it('should show password field when EnableGuestMagicLink is false', async () => { const state = mergeObjects(baseState, { diff --git a/webapp/channels/src/components/login/login.tsx b/webapp/channels/src/components/login/login.tsx index f44c9185e01..4466cac1ca9 100644 --- a/webapp/channels/src/components/login/login.tsx +++ b/webapp/channels/src/components/login/login.tsx @@ -437,23 +437,18 @@ const Login = ({onCustomizeHeader}: LoginProps) => { }, [sessionExpired, formatMessage, onDismissSessionExpired, extraParam, siteName, searchParam]); const getAlternateLink = useCallback(() => { + if (!showSignup) { + return undefined; + } + const linkLabel = formatMessage({ id: 'login.noAccount', defaultMessage: 'Don\'t have an account?', }); - if (showSignup) { - return ( - - ); - } return ( ); diff --git a/webapp/channels/src/components/root/root.tsx b/webapp/channels/src/components/root/root.tsx index 38c71e840f0..f7db6c6cb3f 100644 --- a/webapp/channels/src/components/root/root.tsx +++ b/webapp/channels/src/components/root/root.tsx @@ -50,7 +50,6 @@ const MobileViewWatcher = makeAsyncComponent('MobileViewWatcher', lazy(() => imp const WindowSizeObserver = makeAsyncComponent('WindowSizeObserver', lazy(() => import('components/window_size_observer/WindowSizeObserver'))); const ErrorPage = makeAsyncComponent('ErrorPage', lazy(() => import('components/error_page'))); const Login = makeAsyncComponent('LoginController', lazy(() => import('components/login/login'))); -const AccessProblem = makeAsyncComponent('AccessProblem', lazy(() => import('components/access_problem'))); const PasswordResetSendLink = makeAsyncComponent('PasswordResedSendLink', lazy(() => import('components/password_reset_send_link'))); const PasswordResetForm = makeAsyncComponent('PasswordResetForm', lazy(() => import('components/password_reset_form'))); const Signup = makeAsyncComponent('SignupController', lazy(() => import('components/signup/signup'))); @@ -320,10 +319,6 @@ export default class Root extends React.PureComponent { path={'/login'} component={Login} /> -