syncUser.js 740 B

1234567891011121314151617181920212223242526272829
  1. import {importNewUsers} from './sync';
  2. import LDAP from './ldap';
  3. Meteor.methods({
  4. ldap_sync_now() {
  5. const user = Meteor.user();
  6. if (!user) {
  7. throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'ldap_sync_users' });
  8. }
  9. //TODO: This needs to be fixed - security issue -> alanning:meteor-roles
  10. //if (!RocketChat.authz.hasRole(user._id, 'admin')) {
  11. // throw new Meteor.Error('error-not-authorized', 'Not authorized', { method: 'ldap_sync_users' });
  12. //}
  13. if (LDAP.settings_get('LDAP_ENABLE') !== true) {
  14. throw new Meteor.Error('LDAP_disabled');
  15. }
  16. this.unblock();
  17. importNewUsers();
  18. return {
  19. message: 'Sync_in_progress',
  20. params: [],
  21. };
  22. },
  23. });