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/packages/rocketchat-lib/server/functions/getFullUserData.js

52 lines
1.0 KiB

/* globals RocketChat */
RocketChat.getFullUserData = function({userId, filter, limit}) {
let fields = {
name: 1,
username: 1,
status: 1,
utcOffset: 1,
type: 1,
active: 1,
reason: 1
};
if (RocketChat.authz.hasPermission(userId, 'view-full-other-user-info')) {
fields = _.extend(fields, {
emails: 1,
phone: 1,
statusConnection: 1,
createdAt: 1,
lastLogin: 1,
services: 1,
requirePasswordChange: 1,
requirePasswordChangeReason: 1,
roles: 1,
customFields: 1
});
} else if (limit !== 0) {
limit = 1;
}
filter = s.trim(filter);
if (!filter && limit === 1) {
return undefined;
}
const options = {
fields,
limit,
sort: { username: 1 }
};
if (filter) {
if (limit === 1) {
return RocketChat.models.Users.findByUsername(filter, options);
} else {
const filterReg = new RegExp(s.escapeRegExp(filter), 'i');
return RocketChat.models.Users.findByUsernameNameOrEmailAddress(filterReg, options);
}
}
return RocketChat.models.Users.find({}, options);
};