@@ -22,8 +22,9 @@ RocketChat.API.helperMethods.set('parseJsonQuery', function _parseJsonQuery() {
22
22
// Verify the user's selected fields only contains ones which their role allows
23
23
if ( typeof fields === 'object' ) {
24
24
let nonSelectableFields = Object . keys ( RocketChat . API . v1 . defaultFieldsToExclude ) ;
25
- if ( ! RocketChat . authz . hasPermission ( this . userId , 'view-full-other-user-info' ) && this . request . route . includes ( '/v1/users.' ) ) {
26
- nonSelectableFields = nonSelectableFields . concat ( Object . keys ( RocketChat . API . v1 . limitedUserFieldsToExclude ) ) ;
25
+ if ( this . request . route . includes ( '/v1/users.' ) ) {
26
+ const getFields = ( ) => Object . keys ( RocketChat . authz . hasPermission ( this . userId , 'view-full-other-user-info' ) ? RocketChat . API . v1 . limitedUserFieldsToExcludeIfIsPrivilegedUser : RocketChat . API . v1 . limitedUserFieldsToExclude ) ;
27
+ nonSelectableFields = nonSelectableFields . concat ( getFields ( ) ) ;
27
28
}
28
29
29
30
Object . keys ( fields ) . forEach ( ( k ) => {
@@ -35,8 +36,12 @@ RocketChat.API.helperMethods.set('parseJsonQuery', function _parseJsonQuery() {
35
36
36
37
// Limit the fields by default
37
38
fields = Object . assign ( { } , fields , RocketChat . API . v1 . defaultFieldsToExclude ) ;
38
- if ( ! RocketChat . authz . hasPermission ( this . userId , 'view-full-other-user-info' ) && this . request . route . includes ( '/v1/users.' ) ) {
39
- fields = Object . assign ( fields , RocketChat . API . v1 . limitedUserFieldsToExclude ) ;
39
+ if ( this . request . route . includes ( '/v1/users.' ) ) {
40
+ if ( RocketChat . authz . hasPermission ( this . userId , 'view-full-other-user-info' ) ) {
41
+ fields = Object . assign ( fields , RocketChat . API . v1 . limitedUserFieldsToExcludeIfIsPrivilegedUser ) ;
42
+ } else {
43
+ fields = Object . assign ( fields , RocketChat . API . v1 . limitedUserFieldsToExclude ) ;
44
+ }
40
45
}
41
46
42
47
let query ;
@@ -51,13 +56,17 @@ RocketChat.API.helperMethods.set('parseJsonQuery', function _parseJsonQuery() {
51
56
52
57
// Verify the user has permission to query the fields they are
53
58
if ( typeof query === 'object' ) {
54
- let nonQuerableFields = Object . keys ( RocketChat . API . v1 . defaultFieldsToExclude ) ;
55
- if ( ! RocketChat . authz . hasPermission ( this . userId , 'view-full-other-user-info' ) && this . request . route . includes ( '/v1/users.' ) ) {
56
- nonQuerableFields = nonQuerableFields . concat ( Object . keys ( RocketChat . API . v1 . limitedUserFieldsToExclude ) ) ;
59
+ let nonQueryableFields = Object . keys ( RocketChat . API . v1 . defaultFieldsToExclude ) ;
60
+ if ( this . request . route . includes ( '/v1/users.' ) ) {
61
+ if ( RocketChat . authz . hasPermission ( this . userId , 'view-full-other-user-info' ) ) {
62
+ nonQueryableFields = nonQueryableFields . concat ( Object . keys ( RocketChat . API . v1 . limitedUserFieldsToExcludeIfIsPrivilegedUser ) ) ;
63
+ } else {
64
+ nonQueryableFields = nonQueryableFields . concat ( Object . keys ( RocketChat . API . v1 . limitedUserFieldsToExclude ) ) ;
65
+ }
57
66
}
58
67
59
68
Object . keys ( query ) . forEach ( ( k ) => {
60
- if ( nonQuerableFields . includes ( k ) || nonQuerableFields . includes ( k . split ( RocketChat . API . v1 . fieldSeparator ) [ 0 ] ) ) {
69
+ if ( nonQueryableFields . includes ( k ) || nonQueryableFields . includes ( k . split ( RocketChat . API . v1 . fieldSeparator ) [ 0 ] ) ) {
61
70
delete query [ k ] ;
62
71
}
63
72
} ) ;
0 commit comments