123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- Template.connectionMethod.onCreated(function() {
- this.authenticationMethods = new ReactiveVar([]);
- Meteor.call('getAuthenticationsEnabled', (_, result) => {
- if (result) {
- // 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] })),
- ]);
- }
- // 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 > 1) {
- content.show();
- } else {
- content.hide();
- }
- if (this.authenticationMethods.get().some((method) => method.value === 'oauth2')) {
- $('.at-oauth').show();
- }
- Meteor.call('isPasswordLoginEnabled', (_, result) => {
- if (result) {
- $('.at-pwd-form').show();
- }
- if (result && this.authenticationMethods.get().length > 1) {
- $('.at-sep').show();
- }
- });
- });
- });
- Template.connectionMethod.onRendered(() => {
- // Moves the select boxe in the first place of the at-pwd-form div
- $('.at-form-authentication')
- .detach()
- .prependTo('.at-pwd-form');
- });
- Template.connectionMethod.helpers({
- authentications() {
- return Template.instance().authenticationMethods.get();
- },
- isSelected(match) {
- return Template.instance().data.authenticationMethod === match;
- },
- });
|