style
This commit is contained in:
@@ -144,7 +144,7 @@ async function authorize(req, res, next) {
|
||||
async function userSearch(req, res, next) {
|
||||
debug('user search: dn %s, scope %s, filter %s (from %s)', req.dn.toString(), req.scope, req.filter.toString(), req.connection.ldap.id);
|
||||
|
||||
const [error, result] = await safe(users.list());
|
||||
const [error, allUsers] = await safe(users.list());
|
||||
if (error) return next(new ldap.OperationsError(error.toString()));
|
||||
|
||||
const [groupsError, allGroups] = await safe(groups.listWithMembers());
|
||||
@@ -153,9 +153,9 @@ async function userSearch(req, res, next) {
|
||||
let results = [];
|
||||
|
||||
// send user objects
|
||||
result.forEach(function (user) {
|
||||
for (const user of allUsers) {
|
||||
// skip entries with empty username. Some apps like owncloud can't deal with this
|
||||
if (!user.username) return;
|
||||
if (!user.username) continue;
|
||||
|
||||
const dn = ldap.parseDN(`cn=${user.id},ou=users,dc=cloudron`);
|
||||
|
||||
@@ -195,7 +195,7 @@ async function userSearch(req, res, next) {
|
||||
if ((req.dn.equals(dn) || req.dn.parentOf(dn)) && lowerCaseFilter.matches(obj.attributes)) {
|
||||
results.push(obj);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
finalSend(results, req, res, next);
|
||||
}
|
||||
@@ -203,17 +203,17 @@ async function userSearch(req, res, next) {
|
||||
async function groupSearch(req, res, next) {
|
||||
debug('group search: dn %s, scope %s, filter %s (from %s)', req.dn.toString(), req.scope, req.filter.toString(), req.connection.ldap.id);
|
||||
|
||||
const [error, result] = await safe(users.list());
|
||||
const [error, allUsers] = await safe(users.list());
|
||||
if (error) return next(new ldap.OperationsError(error.toString()));
|
||||
|
||||
const results = [];
|
||||
|
||||
let [errorGroups, resultGroups] = await safe(groups.listWithMembers());
|
||||
let [errorGroups, allGroups] = await safe(groups.listWithMembers());
|
||||
if (errorGroups) return next(new ldap.OperationsError(errorGroups.toString()));
|
||||
|
||||
resultGroups.forEach(function (group) {
|
||||
for (const group of allGroups) {
|
||||
const dn = ldap.parseDN(`cn=${group.name},ou=groups,dc=cloudron`);
|
||||
const members = group.userIds.filter(function (uid) { return result.map(function (u) { return u.id; }).indexOf(uid) !== -1; });
|
||||
const members = group.userIds.filter(function (uid) { return allUsers.map(function (u) { return u.id; }).indexOf(uid) !== -1; });
|
||||
|
||||
const obj = {
|
||||
dn: dn.toString(),
|
||||
@@ -232,7 +232,7 @@ async function groupSearch(req, res, next) {
|
||||
if ((req.dn.equals(dn) || req.dn.parentOf(dn)) && lowerCaseFilter.matches(obj.attributes)) {
|
||||
results.push(obj);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
finalSend(results, req, res, next);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user