Skip to content

Commit

Permalink
MOBILE-4680 login: Fix demo site qr scan hiding
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyserver committed Jan 13, 2025
1 parent 47c8200 commit 6d0dcf2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
31 changes: 25 additions & 6 deletions src/core/features/login/components/login-methods/login-methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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<void> {
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.
*/
Expand Down
7 changes: 0 additions & 7 deletions src/core/features/login/pages/credentials/credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand Down
1 change: 0 additions & 1 deletion src/core/features/login/pages/reconnect/reconnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ export class CoreLoginReconnectPage implements OnInit, OnDestroy {
isLoggedOut: boolean;
siteId!: string;
siteInfo?: CoreSiteBasicInfo;
showScanQR = false;
showLoading = true;
reconnectAttempts = 0;
supportConfig?: CoreUserSupportConfig;
Expand Down
2 changes: 1 addition & 1 deletion src/core/features/login/services/login-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 6d0dcf2

Please sign in to comment.