MOBILE-3676 site: Check qrcode type from site config
parent
5f4a966039
commit
c3210f044d
|
@ -41,6 +41,15 @@ import { CoreLogger } from '@singletons/logger';
|
|||
import { Translate } from '@singletons';
|
||||
import { CoreIonLoadingElement } from './ion-loading';
|
||||
|
||||
/**
|
||||
* QR Code type enumeration.
|
||||
*/
|
||||
export enum CoreSiteQRCodeType {
|
||||
QR_CODE_DISABLED = 0, // QR code disabled value
|
||||
QR_CODE_URL = 1, // QR code type URL value
|
||||
QR_CODE_LOGIN = 2, // QR code type login value
|
||||
}
|
||||
|
||||
/**
|
||||
* Class that represents a site (combination of site + user).
|
||||
* It will have all the site data and provide utility functions regarding a site.
|
||||
|
@ -2122,6 +2131,7 @@ export type CoreSitePublicConfigResponse = {
|
|||
tool_mobile_androidappid?: string; // Android app's unique identifier.
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
tool_mobile_setuplink?: string; // App download page.
|
||||
tool_mobile_qrcodetype?: CoreSiteQRCodeType; // eslint-disable-line @typescript-eslint/naming-convention
|
||||
warnings?: CoreWSExternalWarning[];
|
||||
};
|
||||
|
||||
|
|
|
@ -177,7 +177,7 @@ export class CoreLoginCredentialsPage implements OnInit, OnDestroy {
|
|||
this.siteName = CoreConstants.CONFIG.sitename ? CoreConstants.CONFIG.sitename : this.siteConfig.sitename;
|
||||
this.logoUrl = CoreLoginHelper.getLogoUrl(this.siteConfig);
|
||||
this.authInstructions = this.siteConfig.authinstructions || Translate.instant('core.login.loginsteps');
|
||||
this.showScanQR = CoreLoginHelper.displayQRInCredentialsScreen();
|
||||
this.showScanQR = CoreLoginHelper.displayQRInCredentialsScreen(this.siteConfig.tool_mobile_qrcodetype);
|
||||
|
||||
const disabledFeatures = CoreLoginHelper.getDisabledFeatures(this.siteConfig);
|
||||
this.identityProviders = CoreLoginHelper.getValidIdentityProviders(this.siteConfig, disabledFeatures);
|
||||
|
|
|
@ -135,7 +135,7 @@ export class CoreLoginReconnectPage implements OnInit, OnDestroy {
|
|||
}
|
||||
|
||||
this.showScanQR = CoreLoginHelper.displayQRInSiteScreen() ||
|
||||
CoreLoginHelper.displayQRInCredentialsScreen();
|
||||
CoreLoginHelper.displayQRInCredentialsScreen(this.siteConfig.tool_mobile_qrcodetype);
|
||||
|
||||
await CoreSites.checkApplication(this.siteConfig);
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ import { CoreTextUtils } from '@services/utils/text';
|
|||
import { CoreUrlParams, CoreUrlUtils } from '@services/utils/url';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreConstants } from '@/core/constants';
|
||||
import { CoreSite, CoreSiteIdentityProvider, CoreSitePublicConfigResponse } from '@classes/site';
|
||||
import { CoreSite, CoreSiteIdentityProvider, CoreSitePublicConfigResponse, CoreSiteQRCodeType } from '@classes/site';
|
||||
import { CoreError } from '@classes/errors/error';
|
||||
import { CoreWSError } from '@classes/errors/wserror';
|
||||
import { makeSingleton, Translate } from '@singletons';
|
||||
|
@ -1237,15 +1237,22 @@ export class CoreLoginHelperProvider {
|
|||
/**
|
||||
* Check whether the QR reader should be displayed in credentials screen.
|
||||
*
|
||||
* @param qrCodeType QR Code type from public config, assuming enabled if undefined.
|
||||
* @return Whether the QR reader should be displayed in credentials screen.
|
||||
*/
|
||||
displayQRInCredentialsScreen(): boolean {
|
||||
displayQRInCredentialsScreen(qrCodeType = CoreSiteQRCodeType.QR_CODE_LOGIN): boolean {
|
||||
if (!CoreUtils.canScanQR()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (CoreConstants.CONFIG.displayqroncredentialscreen === undefined && this.isFixedUrlSet()) ||
|
||||
(CoreConstants.CONFIG.displayqroncredentialscreen !== undefined && !!CoreConstants.CONFIG.displayqroncredentialscreen);
|
||||
if ((CoreConstants.CONFIG.displayqroncredentialscreen === undefined && this.isFixedUrlSet()) ||
|
||||
(CoreConstants.CONFIG.displayqroncredentialscreen !== undefined &&
|
||||
!!CoreConstants.CONFIG.displayqroncredentialscreen)) {
|
||||
|
||||
return qrCodeType == CoreSiteQRCodeType.QR_CODE_LOGIN;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue