Fix single speaker

parent 2c12edfb
......@@ -31,6 +31,9 @@ async function checkGroupAdmin(userDN, groupDN, ldap, config){
if (config.adminType == "group") {
if (group.hasOwnProperty(config.fields.group.admin)) {
if (!Array.isArray(group[config.fields.group.admin])) {
group[config.fields.group.admin] = [group[config.fields.group.admin]]
}
if (group[config.fields.group.admin].indexOf(userDN) > -1) {
return true;
} else {
......@@ -52,6 +55,9 @@ async function checkGroupAdmin(userDN, groupDN, ldap, config){
user = entries[0];
if (user.hasOwnProperty(config.fields.user.adminOf)) {
if (!Array.isArray(user[config.fields.user.adminOf])) {
user[config.fields.user.adminOf] = [user[config.fields.user.adminOf]]
}
if (user[config.fields.user.adminOf].indexOf(groupDN) > -1) {
return true;
} else {
......@@ -79,6 +85,9 @@ async function checkGroupSpeaker(userDN, groupDN, ldap, config){
if (config.adminType == "group") {
if (group.hasOwnProperty(config.fields.group.speaker)) {
if (!Array.isArray(group[config.fields.group.speaker])) {
group[config.fields.group.speaker] = [group[config.fields.group.speaker]]
}
if (group[config.fields.group.speaker].indexOf(userDN) > -1) {
return {
name: group[config.fields.displayName.group],
......@@ -103,6 +112,9 @@ async function checkGroupSpeaker(userDN, groupDN, ldap, config){
user = entries[0];
if (user.hasOwnProperty(config.fields.user.speakerOf)) {
if (!Array.isArray(user[config.fields.user.speakerOf])) {
user[config.fields.user.speakerOf] = [user[config.fields.user.speakerOf]]
}
if (user[config.fields.user.speakerOf].indexOf(groupDN) > -1) {
return {
name: group[config.fields.displayName.group],
......@@ -171,6 +183,9 @@ module.exports = function(server, passport, ldap, mailqueue, config) {
user = entries[0];
if (user.hasOwnProperty(config.fields.user.speakerOf)) {
if (!Array.isArray(user[config.fields.user.speakerOf])) {
user[config.fields.user.speakerOf] = [user[config.fields.user.speakerOf]]
}
for (let i = 0; i < user[config.fields.user.speakerOf].length; i++){
let entries = await ldap.search(user[config.fields.user.speakerOf][i], {
scope: "base",
......@@ -450,6 +465,9 @@ module.exports = function(server, passport, ldap, mailqueue, config) {
user = entries[0];
if (user.hasOwnProperty(config.fields.user.adminOf)) {
if (!Array.isArray(user[config.fields.user.adminOf])) {
user[config.fields.user.adminOf] = [user[config.fields.user.adminOf]]
}
for (let i = 0; i < user[config.fields.user.adminOf].length; i++){
out.push({"to.dn": user[config.fields.user.adminOf][i]});
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment