|
|
|
|
@ -22,8 +22,9 @@ RocketChat.API.helperMethods.set('parseJsonQuery', function _parseJsonQuery() { |
|
|
|
|
// Verify the user's selected fields only contains ones which their role allows
|
|
|
|
|
if (typeof fields === 'object') { |
|
|
|
|
let nonSelectableFields = Object.keys(RocketChat.API.v1.defaultFieldsToExclude); |
|
|
|
|
if (!RocketChat.authz.hasPermission(this.userId, 'view-full-other-user-info') && this.request.route.includes('/v1/users.')) { |
|
|
|
|
nonSelectableFields = nonSelectableFields.concat(Object.keys(RocketChat.API.v1.limitedUserFieldsToExclude)); |
|
|
|
|
if (this.request.route.includes('/v1/users.')) { |
|
|
|
|
const getFields = () => Object.keys(RocketChat.authz.hasPermission(this.userId, 'view-full-other-user-info') ? RocketChat.API.v1.limitedUserFieldsToExcludeIfIsPrivilegedUser : RocketChat.API.v1.limitedUserFieldsToExclude); |
|
|
|
|
nonSelectableFields = nonSelectableFields.concat(getFields()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Object.keys(fields).forEach((k) => { |
|
|
|
|
@ -35,8 +36,12 @@ RocketChat.API.helperMethods.set('parseJsonQuery', function _parseJsonQuery() { |
|
|
|
|
|
|
|
|
|
// Limit the fields by default
|
|
|
|
|
fields = Object.assign({}, fields, RocketChat.API.v1.defaultFieldsToExclude); |
|
|
|
|
if (!RocketChat.authz.hasPermission(this.userId, 'view-full-other-user-info') && this.request.route.includes('/v1/users.')) { |
|
|
|
|
fields = Object.assign(fields, RocketChat.API.v1.limitedUserFieldsToExclude); |
|
|
|
|
if (this.request.route.includes('/v1/users.')) { |
|
|
|
|
if (RocketChat.authz.hasPermission(this.userId, 'view-full-other-user-info')) { |
|
|
|
|
fields = Object.assign(fields, RocketChat.API.v1.limitedUserFieldsToExcludeIfIsPrivilegedUser); |
|
|
|
|
} else { |
|
|
|
|
fields = Object.assign(fields, RocketChat.API.v1.limitedUserFieldsToExclude); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let query; |
|
|
|
|
@ -51,13 +56,17 @@ RocketChat.API.helperMethods.set('parseJsonQuery', function _parseJsonQuery() { |
|
|
|
|
|
|
|
|
|
// Verify the user has permission to query the fields they are
|
|
|
|
|
if (typeof query === 'object') { |
|
|
|
|
let nonQuerableFields = Object.keys(RocketChat.API.v1.defaultFieldsToExclude); |
|
|
|
|
if (!RocketChat.authz.hasPermission(this.userId, 'view-full-other-user-info') && this.request.route.includes('/v1/users.')) { |
|
|
|
|
nonQuerableFields = nonQuerableFields.concat(Object.keys(RocketChat.API.v1.limitedUserFieldsToExclude)); |
|
|
|
|
let nonQueryableFields = Object.keys(RocketChat.API.v1.defaultFieldsToExclude); |
|
|
|
|
if (this.request.route.includes('/v1/users.')) { |
|
|
|
|
if (RocketChat.authz.hasPermission(this.userId, 'view-full-other-user-info')) { |
|
|
|
|
nonQueryableFields = nonQueryableFields.concat(Object.keys(RocketChat.API.v1.limitedUserFieldsToExcludeIfIsPrivilegedUser)); |
|
|
|
|
} else { |
|
|
|
|
nonQueryableFields = nonQueryableFields.concat(Object.keys(RocketChat.API.v1.limitedUserFieldsToExclude)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Object.keys(query).forEach((k) => { |
|
|
|
|
if (nonQuerableFields.includes(k) || nonQuerableFields.includes(k.split(RocketChat.API.v1.fieldSeparator)[0])) { |
|
|
|
|
if (nonQueryableFields.includes(k) || nonQueryableFields.includes(k.split(RocketChat.API.v1.fieldSeparator)[0])) { |
|
|
|
|
delete query[k]; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|