From 6d0dcf2d1c078325e26ea230a2f760674df295d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Mon, 13 Jan 2025 16:01:56 +0100 Subject: [PATCH] MOBILE-4680 login: Fix demo site qr scan hiding --- .../components/login-methods/login-methods.ts | 31 +++++++++++++++---- .../login/pages/credentials/credentials.ts | 7 ----- .../login/pages/reconnect/reconnect.ts | 1 - .../features/login/services/login-helper.ts | 2 +- 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/core/features/login/components/login-methods/login-methods.ts b/src/core/features/login/components/login-methods/login-methods.ts index f165bb0aa..6805ded7c 100644 --- a/src/core/features/login/components/login-methods/login-methods.ts +++ b/src/core/features/login/components/login-methods/login-methods.ts @@ -67,8 +67,6 @@ export class CoreLoginMethodsComponent implements OnInit { } if (this.site) { - this.showScanQR = CoreLoginHelper.displayQRInSiteScreen(); - // The identity provider set in the site will be shown at the top. const oAuthId = this.site.getOAuthId(); this.currentLoginProvider = CoreLoginHelper.findIdentityProvider(this.identityProviders, oAuthId); @@ -78,15 +76,36 @@ export class CoreLoginMethodsComponent implements OnInit { provider.url !== this.currentLoginProvider?.url); } - // If still false or credentials screen. - if (!this.site || !this.showScanQR) { - this.showScanQR = await CoreLoginHelper.displayQRInCredentialsScreen(this.siteConfig.tool_mobile_qrcodetype); - } + await this.setShowScanQR(); } this.isReady.resolve(); } + /** + * Set if should show the scan QR code button. + */ + async setShowScanQR(): Promise { + if (this.site) { + if (this.site.isDemoModeSite()) { + this.showScanQR = false; + + return; + } + + this.showScanQR = CoreLoginHelper.displayQRInSiteScreen(); + + if (this.showScanQR) { + return; + } + } + + // If still false or credentials screen. + if (this.siteConfig) { + this.showScanQR = await CoreLoginHelper.displayQRInCredentialsScreen(this.siteConfig.tool_mobile_qrcodetype); + } + } + /** * Show instructions and scan QR code. */ diff --git a/src/core/features/login/pages/credentials/credentials.ts b/src/core/features/login/pages/credentials/credentials.ts index fabf6d53b..57ac284cb 100644 --- a/src/core/features/login/pages/credentials/credentials.ts +++ b/src/core/features/login/pages/credentials/credentials.ts @@ -62,7 +62,6 @@ export class CoreLoginCredentialsPage implements OnInit, OnDestroy { pageLoaded = false; isBrowserSSO = false; showForgottenPassword = true; - showScanQR = false; loginAttempts = 0; supportConfig?: CoreUserSupportConfig; exceededAttemptsHTML?: SafeHtml | string | null; @@ -213,12 +212,6 @@ export class CoreLoginCredentialsPage implements OnInit, OnDestroy { return; } - if (this.site.isDemoModeSite()) { - this.showScanQR = false; - } else { - this.showScanQR = await CoreLoginHelper.displayQRInCredentialsScreen(this.siteConfig.tool_mobile_qrcodetype); - } - this.canSignup = this.siteConfig.registerauth == 'email' && !this.site.isFeatureDisabled(EMAIL_SIGNUP_FEATURE_NAME); this.showForgottenPassword = !this.site.isFeatureDisabled(FORGOTTEN_PASSWORD_FEATURE_NAME); this.exceededAttemptsHTML = CoreLoginHelper.buildExceededAttemptsHTML( diff --git a/src/core/features/login/pages/reconnect/reconnect.ts b/src/core/features/login/pages/reconnect/reconnect.ts index fb0e79408..4c9cb9a69 100644 --- a/src/core/features/login/pages/reconnect/reconnect.ts +++ b/src/core/features/login/pages/reconnect/reconnect.ts @@ -69,7 +69,6 @@ export class CoreLoginReconnectPage implements OnInit, OnDestroy { isLoggedOut: boolean; siteId!: string; siteInfo?: CoreSiteBasicInfo; - showScanQR = false; showLoading = true; reconnectAttempts = 0; supportConfig?: CoreUserSupportConfig; diff --git a/src/core/features/login/services/login-helper.ts b/src/core/features/login/services/login-helper.ts index 4cc29c9d0..fa26b1bf2 100644 --- a/src/core/features/login/services/login-helper.ts +++ b/src/core/features/login/services/login-helper.ts @@ -1269,7 +1269,7 @@ export class CoreLoginHelperProvider { (CoreConstants.CONFIG.displayqroncredentialscreen !== undefined && !!CoreConstants.CONFIG.displayqroncredentialscreen)) { - return qrCodeType == CoreSiteQRCodeType.QR_CODE_LOGIN; + return qrCodeType === CoreSiteQRCodeType.QR_CODE_LOGIN; } return false;