Merge pull request #2238 from dpalou/MOBILE-3279
MOBILE-3279 login: Allow disabling identity providersmain
commit
0d1fd43016
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue