The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/ee/server/api/ldap.ts

30 lines
709 B

import { hasRole } from '../../../app/authorization/server';
import { settings } from '../../../app/settings/server';
import { API } from '../../../app/api/server/api';
import { LDAPEE } from '../sdk';
API.v1.addRoute('ldap.syncNow', {
authRequired: true,
forceTwoFactorAuthenticationForNonEnterprise: true,
twoFactorRequired: true,
}, {
async post() {
if (!this.userId) {
throw new Error('error-invalid-user');
}
if (!hasRole(this.userId, 'admin')) {
throw new Error('error-not-authorized');
}
if (settings.get('LDAP_Enable') !== true) {
throw new Error('LDAP_disabled');
}
await LDAPEE.sync();
return API.v1.success({
message: 'Sync_in_progress' as const,
});
},
});