Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions apps/meteor/app/api/server/default/info.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { API } from '../api';
import { getLoggedInUser } from '../helpers/getLoggedInUser';
import { getServerInfo } from '../lib/getServerInfo';

API.default.addRoute(
'info',
{ authRequired: false },
{
async get() {
const user = await getLoggedInUser(this.request);
return API.v1.success(await getServerInfo(user?._id));
return API.v1.success(await getServerInfo(this.userId));
},
},
);
13 changes: 0 additions & 13 deletions apps/meteor/app/api/server/helpers/getLoggedInUser.ts

This file was deleted.

1 change: 0 additions & 1 deletion apps/meteor/app/api/server/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import './ajv';
import './helpers/composeRoomWithLastMessage';
import './helpers/getLoggedInUser';
import './helpers/getPaginationItems';
import './helpers/getUserFromParams';
import './helpers/getUserInfo';
Expand Down
5 changes: 1 addition & 4 deletions apps/meteor/app/api/server/v1/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ import { normalizeMessagesForUser } from '../../../utils/server/lib/normalizeMes
import { API } from '../api';
import { addUserToFileObj } from '../helpers/addUserToFileObj';
import { composeRoomWithLastMessage } from '../helpers/composeRoomWithLastMessage';
import { getLoggedInUser } from '../helpers/getLoggedInUser';
import { getPaginationItems } from '../helpers/getPaginationItems';
import { getUserFromParams, getUserListFromParams } from '../helpers/getUserFromParams';

Expand Down Expand Up @@ -1147,9 +1146,7 @@ API.v1.addRoute(
return API.v1.failure('Channel does not exists');
}

const user = await getLoggedInUser(this.request);

if (!room || !user || !(await canAccessRoomAsync(room, user))) {
if (!(await canAccessRoomAsync(room, this.user))) {
throw new Meteor.Error('error-not-allowed', 'Not Allowed');
}

Expand Down
4 changes: 1 addition & 3 deletions apps/meteor/app/api/server/v1/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { executeSlashCommandPreview } from '../../../lib/server/methods/executeS
import { getSlashCommandPreviews } from '../../../lib/server/methods/getSlashCommandPreviews';
import { slashCommands } from '../../../utils/server/slashCommand';
import { API } from '../api';
import { getLoggedInUser } from '../helpers/getLoggedInUser';
import { getPaginationItems } from '../helpers/getPaginationItems';

API.v1.addRoute(
Expand Down Expand Up @@ -248,7 +247,6 @@ API.v1.addRoute(
// Expects these query params: command: 'giphy', params: 'mine', roomId: 'value'
async get() {
const query = this.queryParams;
const user = await getLoggedInUser(this.request);

if (typeof query.command !== 'string') {
return API.v1.failure('You must provide a command to get the previews from.');
Expand All @@ -267,7 +265,7 @@ API.v1.addRoute(
return API.v1.failure('The command provided does not exist (or is disabled).');
}

if (!(await canAccessRoomIdAsync(query.roomId, user?._id))) {
if (!(await canAccessRoomIdAsync(query.roomId, this.userId))) {
return API.v1.forbidden();
}

Expand Down
8 changes: 1 addition & 7 deletions apps/meteor/app/api/server/v1/groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import { normalizeMessagesForUser } from '../../../utils/server/lib/normalizeMes
import { API } from '../api';
import { addUserToFileObj } from '../helpers/addUserToFileObj';
import { composeRoomWithLastMessage } from '../helpers/composeRoomWithLastMessage';
import { getLoggedInUser } from '../helpers/getLoggedInUser';
import { getPaginationItems } from '../helpers/getPaginationItems';
import { getUserFromParams, getUserListFromParams } from '../helpers/getUserFromParams';

Expand Down Expand Up @@ -839,12 +838,7 @@ API.v1.addRoute(
return API.v1.failure('Group does not exists');
}

const user = await getLoggedInUser(this.request);
if (!user) {
return API.v1.failure('User does not exists');
}

if (!(await canAccessRoomAsync(room, user))) {
if (!(await canAccessRoomAsync(room, this.user))) {
throw new Meteor.Error('error-not-allowed', 'Not Allowed');
}

Expand Down
3 changes: 1 addition & 2 deletions apps/meteor/app/api/server/v1/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import { getBaseUserFields } from '../../../utils/server/functions/getBaseUserFi
import { isSMTPConfigured } from '../../../utils/server/functions/isSMTPConfigured';
import { getURL } from '../../../utils/server/getURL';
import { API } from '../api';
import { getLoggedInUser } from '../helpers/getLoggedInUser';
import { getPaginationItems } from '../helpers/getPaginationItems';
import { getUserFromParams } from '../helpers/getUserFromParams';
import { getUserInfo } from '../helpers/getUserInfo';
Expand Down Expand Up @@ -244,7 +243,7 @@ API.v1.addRoute(
text = `#${channel}`;
break;
case 'user':
if (settings.get('API_Shield_user_require_auth') && !(await getLoggedInUser(this.request))) {
if (settings.get('API_Shield_user_require_auth') && !this.user) {
return API.v1.failure('You must be logged in to do this.');
}
const user = await getUserFromParams(this.queryParams);
Expand Down
Loading