Skip to content

Commit

Permalink
Chore: Remove unused tokenpass integration code (#25831)
Browse files Browse the repository at this point in the history
<!-- This is a pull request template, you do not need to uncomment or remove the comments, they won't show up in the PR text. -->

<!-- Your Pull Request name should start with one of the following tags
  [NEW] For new features
  [IMPROVE] For an improvement (performance or little improvements) in existing features
  [FIX] For bug fixes that affect the end-user
  [BREAK] For pull requests including breaking changes
  Chore: For small tasks
  Doc: For documentation
-->

<!-- Checklist!!! If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code. 
  - I have read the Contributing Guide - https://github.com/RocketChat/Rocket.Chat/blob/develop/.github/CONTRIBUTING.md#contributing-to-rocketchat doc
  - I have signed the CLA - https://cla-assistant.io/RocketChat/Rocket.Chat
  - Lint and unit tests pass locally with my changes
  - I have added tests that prove my fix is effective or that my feature works (if applicable)
  - I have added necessary documentation (if applicable)
  - Any dependent changes have been merged and published in downstream modules
-->

## Proposed changes (including videos or screenshots)
<!-- CHANGELOG -->
<!--
  Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request.
  If it fixes a bug or resolves a feature request, be sure to link to that issue below.
  This description will appear in the release notes if we accept the contribution.
-->

<!-- END CHANGELOG -->

## Issue(s)
<!-- Link the issues being closed by or related to this PR. For example, you can use #594 if this PR closes issue number 594 -->

## Steps to test or reproduce
<!-- Mention how you would reproduce the bug if not mentioned on the issue page already. Also mention which screens are going to have the changes if applicable -->

## Further comments
<!-- If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc... -->
  • Loading branch information
pierre-lehnen-rc authored Jun 13, 2022
1 parent 22383aa commit 3c1bc07
Show file tree
Hide file tree
Showing 47 changed files with 22 additions and 769 deletions.
2 changes: 0 additions & 2 deletions apps/meteor/app/api/server/v1/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ import { SystemLogger } from '../../../../server/lib/logger/system';
* type: object
* gitlab:
* type: object
* tokenpass:
* type: object
* password:
* type: object
* properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export const roomAccessAttributes = {
t: 1,
teamId: 1,
prid: 1,
tokenpass: 1,
};

export const canAccessRoom = (...args: Parameters<IAuthorization['canAccessRoom']>): boolean => Promise.await(canAccessRoomAsync(...args));
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { Match, check } from 'meteor/check';
import { Match } from 'meteor/check';
import { TEAM_TYPE } from '@rocket.chat/core-typings';

import { setRoomAvatar } from '../../../lib/server/functions/setRoomAvatar';
Expand All @@ -15,7 +15,6 @@ import { saveRoomType } from '../functions/saveRoomType';
import { saveRoomReadOnly } from '../functions/saveRoomReadOnly';
import { saveReactWhenReadOnly } from '../functions/saveReactWhenReadOnly';
import { saveRoomSystemMessages } from '../functions/saveRoomSystemMessages';
import { saveRoomTokenpass } from '../functions/saveRoomTokens';
import { saveRoomEncrypted } from '../functions/saveRoomEncrypted';
import { saveStreamingOptions } from '../functions/saveStreamingOptions';
import { Team } from '../../../../server/sdk';
Expand All @@ -36,7 +35,6 @@ const fields = [
'systemMessages',
'default',
'joinCode',
'tokenpass',
'streamingOptions',
'retentionEnabled',
'retentionMaxAge',
Expand Down Expand Up @@ -195,18 +193,6 @@ const settingSavers = {
Team.update(user._id, room.teamId, { type, updateRoom: false });
}
},
tokenpass({ value, rid }) {
check(value, {
require: String,
tokens: [
{
token: String,
balance: String,
},
],
});
saveRoomTokenpass(rid, value);
},
streamingOptions({ value, rid }) {
saveStreamingOptions(rid, value);
},
Expand Down
16 changes: 0 additions & 16 deletions apps/meteor/app/lib/server/methods/createPrivateGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,6 @@ Meteor.methods({
throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'createPrivateGroup' });
}

// validate extra data schema
check(
extraData,
Match.ObjectIncluding({
tokenpass: Match.Maybe({
require: String,
tokens: [
{
token: String,
balance: String,
},
],
}),
}),
);

return createRoom('p', name, Meteor.user() && Meteor.user().username, members, readOnly, {
customFields,
...extraData,
Expand Down
25 changes: 7 additions & 18 deletions apps/meteor/app/lib/server/methods/joinRoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { check } from 'meteor/check';

import { hasPermission, canAccessRoom } from '../../../authorization/server';
import { Rooms } from '../../../models/server';
import { Tokenpass, updateUserTokenpassBalances } from '../../../tokenpass/server';
import { addUserToRoom } from '../functions';
import { roomCoordinator } from '../../../../server/lib/rooms/roomCoordinator';
import { RoomMemberActions } from '../../../../definition/IRoomTypeConfig';
Expand All @@ -28,23 +27,13 @@ Meteor.methods({
throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'joinRoom' });
}

// TODO we should have a 'beforeJoinRoom' call back so external services can do their own validations

if (room.tokenpass && user && user.services && user.services.tokenpass) {
const balances = updateUserTokenpassBalances(user);

if (!Tokenpass.validateAccess(room.tokenpass, balances)) {
throw new Meteor.Error('error-not-allowed', 'Token required', { method: 'joinRoom' });
}
} else {
if (!canAccessRoom(room, user)) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'joinRoom' });
}
if (room.joinCodeRequired === true && code !== room.joinCode && !hasPermission(user._id, 'join-without-join-code')) {
throw new Meteor.Error('error-code-invalid', 'Invalid Room Password', {
method: 'joinRoom',
});
}
if (!canAccessRoom(room, user)) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'joinRoom' });
}
if (room.joinCodeRequired === true && code !== room.joinCode && !hasPermission(user._id, 'join-without-join-code')) {
throw new Meteor.Error('error-code-invalid', 'Invalid Room Password', {
method: 'joinRoom',
});
}

return addUserToRoom(rid, user);
Expand Down
45 changes: 0 additions & 45 deletions apps/meteor/app/models/server/models/Rooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ export class Rooms extends Base {
this.tryEnsureIndex({ t: 1 });
this.tryEnsureIndex({ 'u._id': 1 });
this.tryEnsureIndex({ ts: 1 });
// Tokenpass
this.tryEnsureIndex({ 'tokenpass.tokens.token': 1 }, { sparse: true });
this.tryEnsureIndex({ tokenpass: 1 }, { sparse: true });
// discussions
this.tryEnsureIndex({ prid: 1 }, { sparse: true });
this.tryEnsureIndex({ fname: 1 }, { sparse: true });
Expand Down Expand Up @@ -95,38 +92,6 @@ export class Rooms extends Base {
return this.update(query, update);
}

findByTokenpass(tokens) {
const query = {
'tokenpass.tokens.token': {
$in: tokens,
},
};

return this._db.find(query).fetch();
}

setTokensById(_id, tokens) {
const update = {
$set: {
'tokenpass.tokens.token': tokens,
},
};

return this.update({ _id }, update);
}

findAllTokenChannels() {
const query = {
tokenpass: { $exists: true },
};
const options = {
fields: {
tokenpass: 1,
},
};
return this._db.find(query, options);
}

setReactionsInLastMessage(roomId, lastMessage) {
return this.update({ _id: roomId }, { $set: { 'lastMessage.reactions': lastMessage.reactions } });
}
Expand Down Expand Up @@ -242,16 +207,6 @@ export class Rooms extends Base {
return this.update({ _id }, update);
}

setTokenpassById(_id, tokenpass) {
const update = {
$set: {
tokenpass,
},
};

return this.update({ _id }, update);
}

setReadOnlyById(_id, readOnly) {
const query = {
_id,
Expand Down
24 changes: 0 additions & 24 deletions apps/meteor/app/models/server/models/Users.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,30 +338,6 @@ export class Users extends Base {
return this.findOne(query, options);
}

setTokenpassTcaBalances(_id, tcaBalances) {
const update = {
$set: {
'services.tokenpass.tcaBalances': tcaBalances,
},
};

return this.update(_id, update);
}

getTokenBalancesByUserId(userId) {
const query = {
_id: userId,
};

const options = {
fields: {
'services.tokenpass.tcaBalances': 1,
},
};

return this.findOne(query, options);
}

roleBaseQuery(userId) {
return { _id: userId };
}
Expand Down
3 changes: 0 additions & 3 deletions apps/meteor/app/tokenpass/README.md

This file was deleted.

47 changes: 0 additions & 47 deletions apps/meteor/app/tokenpass/client/channelSettings.css

This file was deleted.

8 changes: 0 additions & 8 deletions apps/meteor/app/tokenpass/client/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
import '../lib/common';
import './startup';
import './tokenChannelsList.html';
import './tokenChannelsList';
import './tokenpassChannelSettings.html';
import './tokenpassChannelSettings';
import './login-button.css';
import './channelSettings.css';
import './styles.css';
14 changes: 0 additions & 14 deletions apps/meteor/app/tokenpass/client/login-button.css

This file was deleted.

21 changes: 0 additions & 21 deletions apps/meteor/app/tokenpass/client/startup.js

This file was deleted.

12 changes: 0 additions & 12 deletions apps/meteor/app/tokenpass/client/styles.css

This file was deleted.

14 changes: 0 additions & 14 deletions apps/meteor/app/tokenpass/client/tokenChannelsList.html

This file was deleted.

33 changes: 0 additions & 33 deletions apps/meteor/app/tokenpass/client/tokenChannelsList.js

This file was deleted.

Loading

0 comments on commit 3c1bc07

Please sign in to comment.