Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/login/pages/credentials/credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 13 additions & 3 deletions src/core/login/pages/reconnect/reconnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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();
});
Expand All @@ -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);
}

/**
Expand Down
13 changes: 11 additions & 2 deletions src/core/login/providers/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
Expand Down