connectionMethod.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. Template.connectionMethod.onCreated(function() {
  2. this.authenticationMethods = new ReactiveVar([]);
  3. Meteor.call('getAuthenticationsEnabled', (_, result) => {
  4. if (result) {
  5. // TODO : add a management of different languages
  6. // (ex {value: ldap, text: TAPi18n.__('ldap', {}, T9n.getLanguage() || 'en')})
  7. this.authenticationMethods.set([
  8. {value: 'password'},
  9. // Gets only the authentication methods availables
  10. ...Object.entries(result).filter((e) => e[1]).map((e) => ({value: e[0]})),
  11. ]);
  12. }
  13. // If only the default authentication available, hides the select boxe
  14. const content = $('.at-form-authentication');
  15. if (!(this.authenticationMethods.get().length > 1)) {
  16. content.hide();
  17. } else {
  18. content.show();
  19. }
  20. });
  21. });
  22. Template.connectionMethod.onRendered(() => {
  23. // Moves the select boxe in the first place of the at-pwd-form div
  24. $('.at-form-authentication').detach().prependTo('.at-pwd-form');
  25. });
  26. Template.connectionMethod.helpers({
  27. authentications() {
  28. return Template.instance().authenticationMethods.get();
  29. },
  30. });