File tree Expand file tree Collapse file tree 7 files changed +5
-33
lines changed
apps/meteor/app/api/server Expand file tree Collapse file tree 7 files changed +5
-33
lines changed Original file line number Diff line number Diff line change 11import { API } from '../api' ;
2- import { getLoggedInUser } from '../helpers/getLoggedInUser' ;
32import { getServerInfo } from '../lib/getServerInfo' ;
43
54API . default . addRoute (
65 'info' ,
76 { authRequired : false } ,
87 {
98 async get ( ) {
10- const user = await getLoggedInUser ( this . request ) ;
11- return API . v1 . success ( await getServerInfo ( user ?. _id ) ) ;
9+ return API . v1 . success ( await getServerInfo ( this . userId ) ) ;
1210 } ,
1311 } ,
1412) ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11import './ajv' ;
22import './helpers/composeRoomWithLastMessage' ;
3- import './helpers/getLoggedInUser' ;
43import './helpers/getPaginationItems' ;
54import './helpers/getUserFromParams' ;
65import './helpers/getUserInfo' ;
Original file line number Diff line number Diff line change @@ -54,7 +54,6 @@ import { normalizeMessagesForUser } from '../../../utils/server/lib/normalizeMes
5454import { API } from '../api' ;
5555import { addUserToFileObj } from '../helpers/addUserToFileObj' ;
5656import { composeRoomWithLastMessage } from '../helpers/composeRoomWithLastMessage' ;
57- import { getLoggedInUser } from '../helpers/getLoggedInUser' ;
5857import { getPaginationItems } from '../helpers/getPaginationItems' ;
5958import { getUserFromParams , getUserListFromParams } from '../helpers/getUserFromParams' ;
6059
@@ -1147,9 +1146,7 @@ API.v1.addRoute(
11471146 return API . v1 . failure ( 'Channel does not exists' ) ;
11481147 }
11491148
1150- const user = await getLoggedInUser ( this . request ) ;
1151-
1152- if ( ! room || ! user || ! ( await canAccessRoomAsync ( room , user ) ) ) {
1149+ if ( ! ( await canAccessRoomAsync ( room , this . user ) ) ) {
11531150 throw new Meteor . Error ( 'error-not-allowed' , 'Not Allowed' ) ;
11541151 }
11551152
Original file line number Diff line number Diff line change @@ -8,7 +8,6 @@ import { executeSlashCommandPreview } from '../../../lib/server/methods/executeS
88import { getSlashCommandPreviews } from '../../../lib/server/methods/getSlashCommandPreviews' ;
99import { slashCommands } from '../../../utils/server/slashCommand' ;
1010import { API } from '../api' ;
11- import { getLoggedInUser } from '../helpers/getLoggedInUser' ;
1211import { getPaginationItems } from '../helpers/getPaginationItems' ;
1312
1413API . v1 . addRoute (
@@ -248,7 +247,6 @@ API.v1.addRoute(
248247 // Expects these query params: command: 'giphy', params: 'mine', roomId: 'value'
249248 async get ( ) {
250249 const query = this . queryParams ;
251- const user = await getLoggedInUser ( this . request ) ;
252250
253251 if ( typeof query . command !== 'string' ) {
254252 return API . v1 . failure ( 'You must provide a command to get the previews from.' ) ;
@@ -267,7 +265,7 @@ API.v1.addRoute(
267265 return API . v1 . failure ( 'The command provided does not exist (or is disabled).' ) ;
268266 }
269267
270- if ( ! ( await canAccessRoomIdAsync ( query . roomId , user ?. _id ) ) ) {
268+ if ( ! ( await canAccessRoomIdAsync ( query . roomId , this . userId ) ) ) {
271269 return API . v1 . forbidden ( ) ;
272270 }
273271
Original file line number Diff line number Diff line change @@ -34,7 +34,6 @@ import { normalizeMessagesForUser } from '../../../utils/server/lib/normalizeMes
3434import { API } from '../api' ;
3535import { addUserToFileObj } from '../helpers/addUserToFileObj' ;
3636import { composeRoomWithLastMessage } from '../helpers/composeRoomWithLastMessage' ;
37- import { getLoggedInUser } from '../helpers/getLoggedInUser' ;
3837import { getPaginationItems } from '../helpers/getPaginationItems' ;
3938import { getUserFromParams , getUserListFromParams } from '../helpers/getUserFromParams' ;
4039
@@ -839,12 +838,7 @@ API.v1.addRoute(
839838 return API . v1 . failure ( 'Group does not exists' ) ;
840839 }
841840
842- const user = await getLoggedInUser ( this . request ) ;
843- if ( ! user ) {
844- return API . v1 . failure ( 'User does not exists' ) ;
845- }
846-
847- if ( ! ( await canAccessRoomAsync ( room , user ) ) ) {
841+ if ( ! ( await canAccessRoomAsync ( room , this . user ) ) ) {
848842 throw new Meteor . Error ( 'error-not-allowed' , 'Not Allowed' ) ;
849843 }
850844
Original file line number Diff line number Diff line change @@ -29,7 +29,6 @@ import { getBaseUserFields } from '../../../utils/server/functions/getBaseUserFi
2929import { isSMTPConfigured } from '../../../utils/server/functions/isSMTPConfigured' ;
3030import { getURL } from '../../../utils/server/getURL' ;
3131import { API } from '../api' ;
32- import { getLoggedInUser } from '../helpers/getLoggedInUser' ;
3332import { getPaginationItems } from '../helpers/getPaginationItems' ;
3433import { getUserFromParams } from '../helpers/getUserFromParams' ;
3534import { getUserInfo } from '../helpers/getUserInfo' ;
@@ -244,7 +243,7 @@ API.v1.addRoute(
244243 text = `#${ channel } ` ;
245244 break ;
246245 case 'user' :
247- if ( settings . get ( 'API_Shield_user_require_auth' ) && ! ( await getLoggedInUser ( this . request ) ) ) {
246+ if ( settings . get ( 'API_Shield_user_require_auth' ) && ! this . user ) {
248247 return API . v1 . failure ( 'You must be logged in to do this.' ) ;
249248 }
250249 const user = await getUserFromParams ( this . queryParams ) ;
You can’t perform that action at this time.
0 commit comments