From 080a02112695790bfc4ec3f3bda405c6d117fd0b Mon Sep 17 00:00:00 2001 From: Mattermost Build Date: Tue, 27 Aug 2024 14:53:12 +0200 Subject: [PATCH] fix sso login success message (#8174) (#8180) * fix sso login success message * fix if statement --------- Co-authored-by: Mattermost Build (cherry picked from commit 8b869c246b387a1eedb2bec1008bab87f5f2139e) Co-authored-by: Elias Nahum --- app/products/calls/types/calls.ts | 1 + app/screens/sso/sso_authentication.tsx | 108 ++++++++++++++++--------- assets/base/i18n/en.json | 2 + 3 files changed, 72 insertions(+), 39 deletions(-) diff --git a/app/products/calls/types/calls.ts b/app/products/calls/types/calls.ts index c1d5111fa25..b8803bafbbc 100644 --- a/app/products/calls/types/calls.ts +++ b/app/products/calls/types/calls.ts @@ -151,6 +151,7 @@ export type CallsConnection = { export type CallsConfigState = CallsConfig & { AllowEnableCalls: boolean; + GroupCallsAllowed: boolean; pluginEnabled: boolean; version: CallsVersion; last_retrieved_at: number; diff --git a/app/screens/sso/sso_authentication.tsx b/app/screens/sso/sso_authentication.tsx index fbdbbf77f27..5e6d6fbc4b0 100644 --- a/app/screens/sso/sso_authentication.tsx +++ b/app/screens/sso/sso_authentication.tsx @@ -10,6 +10,7 @@ import {Linking, Platform, Text, View, type EventSubscription} from 'react-nativ import urlParse from 'url-parse'; import FormattedText from '@components/formatted_text'; +import Loading from '@components/loading'; import {Sso} from '@constants'; import NetworkManager from '@managers/network_manager'; import {buttonBackgroundStyle, buttonTextStyle} from '@utils/buttonStyles'; @@ -59,6 +60,7 @@ const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => { const SSOAuthentication = ({doSSOLogin, loginError, loginUrl, serverUrl, setLoginError, theme}: SSOWithRedirectURLProps) => { const [error, setError] = useState(''); + const [loginSuccess, setLoginSuccess] = useState(false); const style = getStyleSheet(theme); const intl = useIntl(); let customUrlScheme = Sso.REDIRECT_URL_SCHEME; @@ -68,6 +70,7 @@ const SSOAuthentication = ({doSSOLogin, loginError, loginUrl, serverUrl, setLogi const redirectUrl = customUrlScheme + 'callback'; const init = async (resetErrors = true) => { + setLoginSuccess(false); if (resetErrors !== false) { setError(''); setLoginError(''); @@ -87,6 +90,7 @@ const SSOAuthentication = ({doSSOLogin, loginError, loginUrl, serverUrl, setLogi const bearerToken = resultUrl.query?.MMAUTHTOKEN; const csrfToken = resultUrl.query?.MMCSRF; if (bearerToken && csrfToken) { + setLoginSuccess(true); doSSOLogin(bearerToken, csrfToken); } } else if (Platform.OS === 'ios' || result.type === 'dismiss') { @@ -110,6 +114,7 @@ const SSOAuthentication = ({doSSOLogin, loginError, loginUrl, serverUrl, setLogi const bearerToken = parsedUrl.query?.MMAUTHTOKEN; const csrfToken = parsedUrl.query?.MMCSRF; if (bearerToken && csrfToken) { + setLoginSuccess(true); doSSOLogin(bearerToken, csrfToken); } else { setError( @@ -135,50 +140,75 @@ const SSOAuthentication = ({doSSOLogin, loginError, loginUrl, serverUrl, setLogi }; }, []); + let content; + if (loginSuccess) { + content = ( + + + + + + ); + } else if (loginError || error) { + content = ( + + + + {`${loginError || error}.`} + + + + ); + } else { + content = ( + + + + + ); + } + return ( - {loginError || error ? ( - - - - {`${loginError || error}.`} - - - - ) : ( - - - - - )} + {content} ); }; diff --git a/assets/base/i18n/en.json b/assets/base/i18n/en.json index e03c2695e82..27e7df620fe 100644 --- a/assets/base/i18n/en.json +++ b/assets/base/i18n/en.json @@ -703,6 +703,8 @@ "mobile.no_results.spelling": "Check the spelling or try another search.", "mobile.oauth.failed_to_login": "Your login attempt failed. Please try again.", "mobile.oauth.something_wrong.okButton": "OK", + "mobile.oauth.success.description": "Signing in now, just a moment...", + "mobile.oauth.success.title": "Authentication successful", "mobile.oauth.switch_to_browser": "You are being redirected to your login provider", "mobile.oauth.switch_to_browser.error_title": "Sign in error", "mobile.oauth.switch_to_browser.title": "Redirecting...",