diff --git a/src/core/login/pages/credentials/credentials.ts b/src/core/login/pages/credentials/credentials.ts index ed0b43d0e..13b81d12c 100644 --- a/src/core/login/pages/credentials/credentials.ts +++ b/src/core/login/pages/credentials/credentials.ts @@ -155,9 +155,9 @@ export class CoreLoginCredentialsPage { this.siteName = CoreConfigConstants.sitename ? CoreConfigConstants.sitename : this.siteConfig.sitename; this.logoUrl = this.siteConfig.logourl || this.siteConfig.compactlogourl; this.authInstructions = this.siteConfig.authinstructions || this.translate.instant('core.login.loginsteps'); - this.identityProviders = this.loginHelper.getValidIdentityProviders(this.siteConfig); const disabledFeatures = this.loginHelper.getDisabledFeatures(this.siteConfig); + this.identityProviders = this.loginHelper.getValidIdentityProviders(this.siteConfig, disabledFeatures); this.canSignup = this.siteConfig.registerauth == 'email' && !this.loginHelper.isEmailSignupDisabled(this.siteConfig, disabledFeatures); this.showForgottenPassword = !this.loginHelper.isForgottenPasswordDisabled(this.siteConfig, disabledFeatures); diff --git a/src/core/login/pages/reconnect/reconnect.ts b/src/core/login/pages/reconnect/reconnect.ts index afa776e21..b735b4db5 100644 --- a/src/core/login/pages/reconnect/reconnect.ts +++ b/src/core/login/pages/reconnect/reconnect.ts @@ -74,8 +74,7 @@ export class CoreLoginReconnectPage { */ ionViewDidLoad(): void { if (this.siteConfig) { - this.identityProviders = this.loginHelper.getValidIdentityProviders(this.siteConfig); - this.showForgottenPassword = !this.loginHelper.isForgottenPasswordDisabled(this.siteConfig); + this.getDataFromConfig(this.siteConfig); } this.sitesProvider.getSite(this.siteId).then((site) => { @@ -100,7 +99,7 @@ export class CoreLoginReconnectPage { this.logoUrl = config.logourl || config.compactlogourl; } - this.showForgottenPassword = !this.loginHelper.isForgottenPasswordDisabled(config); + this.getDataFromConfig(this.siteConfig); }).catch(() => { this.cancel(); }); @@ -111,7 +110,18 @@ export class CoreLoginReconnectPage { // Shouldn't happen. Just leave the view. this.cancel(); }); + } + /** + * Get some data (like identity providers) from the site config. + * + * @param config Config to use. + */ + protected getDataFromConfig(config: any): void { + const disabledFeatures = this.loginHelper.getDisabledFeatures(config); + + this.identityProviders = this.loginHelper.getValidIdentityProviders(config, disabledFeatures); + this.showForgottenPassword = !this.loginHelper.isForgottenPasswordDisabled(config); } /** diff --git a/src/core/login/providers/helper.ts b/src/core/login/providers/helper.ts index 34cadb2f9..b05fa15c9 100644 --- a/src/core/login/providers/helper.ts +++ b/src/core/login/providers/helper.ts @@ -430,16 +430,25 @@ export class CoreLoginHelperProvider { * Get the valid identity providers from a site config. * * @param siteConfig Site's public config. + * @param disabledFeatures List of disabled features already treated. If not provided it will be calculated. * @return Valid identity providers. */ - getValidIdentityProviders(siteConfig: any): any[] { + getValidIdentityProviders(siteConfig: any, disabledFeatures?: string): any[] { + if (this.isFeatureDisabled('NoDelegate_IdentityProviders', siteConfig, disabledFeatures)) { + // Identity providers are disabled, return an empty list. + return []; + } + const validProviders = [], httpUrl = this.textUtils.concatenatePaths(siteConfig.wwwroot, 'auth/oauth2/'), httpsUrl = this.textUtils.concatenatePaths(siteConfig.httpswwwroot, 'auth/oauth2/'); if (siteConfig.identityproviders && siteConfig.identityproviders.length) { siteConfig.identityproviders.forEach((provider) => { - if (provider.url && (provider.url.indexOf(httpsUrl) != -1 || provider.url.indexOf(httpUrl) != -1)) { + const urlParams = this.urlUtils.extractUrlParams(provider.url); + + if (provider.url && (provider.url.indexOf(httpsUrl) != -1 || provider.url.indexOf(httpUrl) != -1) && + !this.isFeatureDisabled('NoDelegate_IdentityProvider_' + urlParams.id, siteConfig, disabledFeatures)) { validProviders.push(provider); } });