From f190a102f9e5ca67e6af31743d7fc29e765fcadb Mon Sep 17 00:00:00 2001 From: Johannes Zellner Date: Thu, 3 Aug 2023 16:41:24 +0200 Subject: [PATCH 1/4] formAuthenticationMethods is an array part of #5051 --- client/components/settings/connectionMethod.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/components/settings/connectionMethod.js b/client/components/settings/connectionMethod.js index 9eea66ec0..dd0201835 100644 --- a/client/components/settings/connectionMethod.js +++ b/client/components/settings/connectionMethod.js @@ -18,7 +18,7 @@ Template.connectionMethod.onCreated(function() { const content = $('.at-form-authentication'); // OAuth method is a separate button, so ignore it in the count const formAuthenticationMethods = this.authenticationMethods.get().filter((method) => method.value !== 'oauth2'); - if (formAuthenticationMethods > 1) { + if (formAuthenticationMethods.length > 1) { content.show(); } else { content.hide(); From bda166ba500d9a67c4983f2f9f371c8916d02c05 Mon Sep 17 00:00:00 2001 From: Johannes Zellner Date: Thu, 3 Aug 2023 16:53:23 +0200 Subject: [PATCH 2/4] Ensure we subscribe to currentSettings in login view --- client/components/main/layouts.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/client/components/main/layouts.js b/client/components/main/layouts.js index 090809bab..c1652f2f2 100644 --- a/client/components/main/layouts.js +++ b/client/components/main/layouts.js @@ -35,6 +35,13 @@ Template.userFormsLayout.onCreated(function () { Meteor.loginWithOidc(options); } }); + + Meteor.subscribe('setting', { + onReady() { + templateInstance.currentSetting.set(ReactiveCache.getCurrentSetting()); + return this.stop(); + }, + }); } }); From 99d9291a28c72ec267cfda83033b6969feae8e68 Mon Sep 17 00:00:00 2001 From: Johannes Zellner Date: Thu, 3 Aug 2023 17:00:31 +0200 Subject: [PATCH 3/4] Never show the login form OR separator So many states for with password enabled/disabled treated async separately. Might be easier to bring back once password login is treated like saml/ldap/... while still using the very same form elements regardless --- client/components/main/layouts.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/client/components/main/layouts.js b/client/components/main/layouts.js index c1652f2f2..6ebe6d22e 100644 --- a/client/components/main/layouts.js +++ b/client/components/main/layouts.js @@ -59,10 +59,6 @@ Template.userFormsLayout.onRendered(() => { if (result) { $('.at-pwd-form').show(); } - - if (result && enabledAuthenticationMethods.length > 1) { - $('.at-sep').show(); - } }); Meteor.call('isDisableRegistration', (_, result) => { From d93a58d892422fa1059badd26ffa078f45127066 Mon Sep 17 00:00:00 2001 From: Johannes Zellner Date: Thu, 3 Aug 2023 17:17:08 +0200 Subject: [PATCH 4/4] Do not show OAuth2 in auth method dropdown as it has its own button --- client/components/settings/connectionMethod.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/client/components/settings/connectionMethod.js b/client/components/settings/connectionMethod.js index dd0201835..bc6d477f6 100644 --- a/client/components/settings/connectionMethod.js +++ b/client/components/settings/connectionMethod.js @@ -3,22 +3,18 @@ Template.connectionMethod.onCreated(function() { Meteor.call('getAuthenticationsEnabled', (_, result) => { if (result) { + // Only enabled auth methods without OAuth2/OpenID which is a separate button + const tmp = Object.keys(result).filter((k) => result[k]).filter((k) => k !== 'oauth2'); + // TODO : add a management of different languages // (ex {value: ldap, text: TAPi18n.__('ldap', {}, T9n.getLanguage() || 'en')}) - this.authenticationMethods.set([ - { value: 'password' }, - // Gets only the authentication methods availables - ...Object.entries(result) - .filter(e => e[1]) - .map(e => ({ value: e[0] })), - ]); + this.authenticationMethods.set([{ value: 'password' }].concat(tmp.map((k) => { return { value: k }; }))); } // If only the default authentication available, hides the select boxe const content = $('.at-form-authentication'); - // OAuth method is a separate button, so ignore it in the count - const formAuthenticationMethods = this.authenticationMethods.get().filter((method) => method.value !== 'oauth2'); - if (formAuthenticationMethods.length > 1) { + + if (this.authenticationMethods.get().length > 1) { content.show(); } else { content.hide();