-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NEW] Option to reset e2e key (#12483)
* Added option to reset e2e key * Reset e2e key
- Loading branch information
Showing
11 changed files
with
135 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
packages/rocketchat-e2e/server/methods/requestSubscriptionKeys.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Meteor } from 'meteor/meteor'; | ||
import { RocketChat } from 'meteor/rocketchat:lib'; | ||
|
||
Meteor.methods({ | ||
'e2e.requestSubscriptionKeys'() { | ||
if (!Meteor.userId()) { | ||
throw new Meteor.Error('error-invalid-user', 'Invalid user', { | ||
method: 'requestSubscriptionKeys', | ||
}); | ||
} | ||
|
||
// Get all encrypted rooms that the user is subscribed to | ||
|
||
const subscriptions = RocketChat.models.Subscriptions.findByUserId(Meteor.userId()); | ||
const roomIds = subscriptions.map((subscription) => subscription.rid); | ||
|
||
const query = { | ||
e2eKeyId : { | ||
$exists: true, | ||
}, | ||
_id : { | ||
$in: roomIds, | ||
}, | ||
}; | ||
|
||
const rooms = RocketChat.models.Rooms.find(query); | ||
rooms.forEach((room) => { | ||
RocketChat.Notifications.notifyRoom('e2e.keyRequest', room._id, room.e2eKeyId); | ||
}); | ||
|
||
return true; | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Meteor } from 'meteor/meteor'; | ||
import { RocketChat } from 'meteor/rocketchat:lib'; | ||
|
||
Meteor.methods({ | ||
'e2e.resetUserE2EKey'(userId) { | ||
if (!Meteor.userId()) { | ||
throw new Meteor.Error('error-invalid-user', 'Invalid user', { | ||
method: 'resetUserE2EKey', | ||
}); | ||
} | ||
|
||
if (RocketChat.authz.hasPermission(Meteor.userId(), 'reset-other-user-e2e-key') !== true) { | ||
throw new Meteor.Error('error-not-allowed', 'Not allowed', { | ||
method: 'resetUserE2EKey', | ||
}); | ||
} | ||
|
||
RocketChat.models.Users.resetE2EKey(userId); | ||
RocketChat.models.Subscriptions.resetUserE2EKey(userId); | ||
|
||
// Force the user to logout, so that the keys can be generated again | ||
RocketChat.models.Users.removeResumeService(userId); | ||
return true; | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters