Skip to content

Commit 11753a4

Browse files
authored
Merge pull request #4283 from crazyserver/MOBILE-4680
MOBILE-4680 login: Fix demo site qr scan hiding
2 parents 47c8200 + 6d0dcf2 commit 11753a4

File tree

4 files changed

+26
-15
lines changed

4 files changed

+26
-15
lines changed

src/core/features/login/components/login-methods/login-methods.ts

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ export class CoreLoginMethodsComponent implements OnInit {
6767
}
6868

6969
if (this.site) {
70-
this.showScanQR = CoreLoginHelper.displayQRInSiteScreen();
71-
7270
// The identity provider set in the site will be shown at the top.
7371
const oAuthId = this.site.getOAuthId();
7472
this.currentLoginProvider = CoreLoginHelper.findIdentityProvider(this.identityProviders, oAuthId);
@@ -78,15 +76,36 @@ export class CoreLoginMethodsComponent implements OnInit {
7876
provider.url !== this.currentLoginProvider?.url);
7977
}
8078

81-
// If still false or credentials screen.
82-
if (!this.site || !this.showScanQR) {
83-
this.showScanQR = await CoreLoginHelper.displayQRInCredentialsScreen(this.siteConfig.tool_mobile_qrcodetype);
84-
}
79+
await this.setShowScanQR();
8580
}
8681

8782
this.isReady.resolve();
8883
}
8984

85+
/**
86+
* Set if should show the scan QR code button.
87+
*/
88+
async setShowScanQR(): Promise<void> {
89+
if (this.site) {
90+
if (this.site.isDemoModeSite()) {
91+
this.showScanQR = false;
92+
93+
return;
94+
}
95+
96+
this.showScanQR = CoreLoginHelper.displayQRInSiteScreen();
97+
98+
if (this.showScanQR) {
99+
return;
100+
}
101+
}
102+
103+
// If still false or credentials screen.
104+
if (this.siteConfig) {
105+
this.showScanQR = await CoreLoginHelper.displayQRInCredentialsScreen(this.siteConfig.tool_mobile_qrcodetype);
106+
}
107+
}
108+
90109
/**
91110
* Show instructions and scan QR code.
92111
*/

src/core/features/login/pages/credentials/credentials.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ export class CoreLoginCredentialsPage implements OnInit, OnDestroy {
6262
pageLoaded = false;
6363
isBrowserSSO = false;
6464
showForgottenPassword = true;
65-
showScanQR = false;
6665
loginAttempts = 0;
6766
supportConfig?: CoreUserSupportConfig;
6867
exceededAttemptsHTML?: SafeHtml | string | null;
@@ -213,12 +212,6 @@ export class CoreLoginCredentialsPage implements OnInit, OnDestroy {
213212
return;
214213
}
215214

216-
if (this.site.isDemoModeSite()) {
217-
this.showScanQR = false;
218-
} else {
219-
this.showScanQR = await CoreLoginHelper.displayQRInCredentialsScreen(this.siteConfig.tool_mobile_qrcodetype);
220-
}
221-
222215
this.canSignup = this.siteConfig.registerauth == 'email' && !this.site.isFeatureDisabled(EMAIL_SIGNUP_FEATURE_NAME);
223216
this.showForgottenPassword = !this.site.isFeatureDisabled(FORGOTTEN_PASSWORD_FEATURE_NAME);
224217
this.exceededAttemptsHTML = CoreLoginHelper.buildExceededAttemptsHTML(

src/core/features/login/pages/reconnect/reconnect.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ export class CoreLoginReconnectPage implements OnInit, OnDestroy {
6969
isLoggedOut: boolean;
7070
siteId!: string;
7171
siteInfo?: CoreSiteBasicInfo;
72-
showScanQR = false;
7372
showLoading = true;
7473
reconnectAttempts = 0;
7574
supportConfig?: CoreUserSupportConfig;

src/core/features/login/services/login-helper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,7 @@ export class CoreLoginHelperProvider {
12691269
(CoreConstants.CONFIG.displayqroncredentialscreen !== undefined &&
12701270
!!CoreConstants.CONFIG.displayqroncredentialscreen)) {
12711271

1272-
return qrCodeType == CoreSiteQRCodeType.QR_CODE_LOGIN;
1272+
return qrCodeType === CoreSiteQRCodeType.QR_CODE_LOGIN;
12731273
}
12741274

12751275
return false;

0 commit comments

Comments
 (0)