summaryrefslogtreecommitdiffstats
path: root/packages/wekan-ldap/server/syncUser.js
blob: 763ea836de344c4c227ee27a1b89530931a363d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import {importNewUsers} from './sync';
import LDAP from './ldap';

Meteor.methods({
  ldap_sync_now() {
    const user = Meteor.user();
    if (!user) {
      throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'ldap_sync_users' });
    }

    //TODO: This needs to be fixed - security issue -> alanning:meteor-roles
    //if (!RocketChat.authz.hasRole(user._id, 'admin')) {
    //	throw new Meteor.Error('error-not-authorized', 'Not authorized', { method: 'ldap_sync_users' });
    //}

    if (LDAP.settings_get('LDAP_ENABLE') !== true) {
      throw new Meteor.Error('LDAP_disabled');
    }

    this.unblock();

    importNewUsers();

    return {
      message: 'Sync_in_progress',
      params: [],
    };
  },
});