2018-12-24 18:18:41 +02:00
|
|
|
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([
|
2019-06-28 12:52:09 -05:00
|
|
|
{ value: 'password' },
|
2018-12-24 18:18:41 +02:00
|
|
|
// Gets only the authentication methods availables
|
2019-06-28 12:52:09 -05:00
|
|
|
...Object.entries(result)
|
|
|
|
|
.filter(e => e[1])
|
|
|
|
|
.map(e => ({ value: e[0] })),
|
2018-12-24 18:18:41 +02:00
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If only the default authentication available, hides the select boxe
|
|
|
|
|
const content = $('.at-form-authentication');
|
2023-08-01 12:57:25 +02:00
|
|
|
// OAuth method is a separate button, so ignore it in the count
|
|
|
|
|
const formAuthenticationMethods = this.authenticationMethods.get().filter((method) => method.value !== 'oauth2');
|
2023-08-03 16:41:24 +02:00
|
|
|
if (formAuthenticationMethods.length > 1) {
|
2018-12-24 18:18:41 +02:00
|
|
|
content.show();
|
2023-08-01 12:57:25 +02:00
|
|
|
} else {
|
|
|
|
|
content.hide();
|
2018-12-24 18:18:41 +02:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Template.connectionMethod.onRendered(() => {
|
|
|
|
|
// Moves the select boxe in the first place of the at-pwd-form div
|
2019-06-28 12:52:09 -05:00
|
|
|
$('.at-form-authentication')
|
|
|
|
|
.detach()
|
|
|
|
|
.prependTo('.at-pwd-form');
|
2018-12-24 18:18:41 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Template.connectionMethod.helpers({
|
|
|
|
|
authentications() {
|
|
|
|
|
return Template.instance().authenticationMethods.get();
|
|
|
|
|
},
|
2019-02-15 17:06:05 +01:00
|
|
|
isSelected(match) {
|
|
|
|
|
return Template.instance().data.authenticationMethod === match;
|
|
|
|
|
},
|
2018-12-24 18:18:41 +02:00
|
|
|
});
|