2022-05-16 21:12:27 +03:00
|
|
|
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' });
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-18 19:36:28 +02:00
|
|
|
if (!user.isAdmin) {
|
|
|
|
|
throw new Meteor.Error('error-not-authorized', 'Not authorized', { method: 'ldap_sync_users' });
|
|
|
|
|
}
|
2022-05-16 21:12:27 +03:00
|
|
|
|
|
|
|
|
if (LDAP.settings_get('LDAP_ENABLE') !== true) {
|
|
|
|
|
throw new Meteor.Error('LDAP_disabled');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.unblock();
|
|
|
|
|
|
|
|
|
|
importNewUsers();
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
message: 'Sync_in_progress',
|
|
|
|
|
params: [],
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
});
|