Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] /groups.invite not allow a user to invite even with permission #11010

Merged
merged 7 commits into from
Jun 15, 2018

Conversation

MarcosSpessatto
Copy link
Member

Closes #10639

@MarcosSpessatto MarcosSpessatto added this to the 0.66.0 milestone Jun 5, 2018
@MarcosSpessatto MarcosSpessatto self-assigned this Jun 5, 2018
@MarcosSpessatto MarcosSpessatto changed the title [FIX] Fix REST groups invite, that did not allow a user to invite even with permission [FIX] REST groups invite, that did not allow a user to invite even with permission Jun 5, 2018
@engelgabriel engelgabriel temporarily deployed to rocket-chat-pr-11010 June 5, 2018 18:50 Inactive
@ggazzo ggazzo requested a review from Hudell June 11, 2018 21:30
const params = this.requestParams();
if (canAddUserToAnyPrivateGroup) {
if (params.roomId && params.roomId.trim()) {
findResult = RocketChat.models.Subscriptions.findByRoomId(params.roomId).fetch()[0];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not find the room directly? Looking for subscriptions will cause the code to fail on empty rooms.

@@ -54,6 +54,14 @@ class ModelSubscriptions extends RocketChat.models._Base {
return this.findOne(query);
}

findOneByRoomName(roomName) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you use the room directly, this method won't be necessary.

Copy link
Member

@ggazzo ggazzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the problem is here findPrivateGroupByIdOrName. if i'm not mistaken, we have the same problem for more endpoints, please check the functions that use findPrivateGroupByIdOrName and let me know if I made some confusion, but I think all these methods just works if you are joined in the room(even if you are an admin)...

@Hudell
Copy link
Contributor

Hudell commented Jun 13, 2018

@ggazzo Those methods don't work if you've not joined the room.

@engelgabriel engelgabriel temporarily deployed to rocket-chat-pr-11010 June 13, 2018 15:20 Inactive
@engelgabriel engelgabriel temporarily deployed to rocket-chat-pr-11010 June 13, 2018 15:21 Inactive
Hudell
Hudell previously requested changes Jun 13, 2018

const user = this.getUserFromParams();

Meteor.runAsUser(this.userId, () => {
Meteor.call('addUserToRoom', { rid: findResult.rid, username: user.username });
Meteor.call('addUserToRoom', { rid: findResult._id, username: user.username });

This comment was marked as resolved.

@engelgabriel engelgabriel temporarily deployed to rocket-chat-pr-11010 June 13, 2018 18:09 Inactive
@engelgabriel engelgabriel temporarily deployed to rocket-chat-pr-11010 June 13, 2018 18:16 Inactive
@Hudell
Copy link
Contributor

Hudell commented Jun 13, 2018

The current solution works perfectly. Can you check if there are more endpoints using the findPrivateGroupByIdOrName method, where the same problem may be happening?

@ggazzo
Copy link
Member

ggazzo commented Jun 13, 2018

I think for this case you should just call the dpp method

@engelgabriel engelgabriel temporarily deployed to rocket-chat-pr-11010 June 14, 2018 20:00 Inactive
@Hudell Hudell dismissed their stale review June 14, 2018 20:13

Changes were made

@ggazzo ggazzo temporarily deployed to rocket-chat-pr-11010 June 15, 2018 16:19 Inactive
@ggazzo ggazzo changed the title [FIX] REST groups invite, that did not allow a user to invite even with permission [FIX] /groups.invite not allow a user to invite even with permission Jun 15, 2018
@ggazzo ggazzo merged commit 85b662b into develop Jun 15, 2018
@ggazzo ggazzo deleted the fix-rest-groups-invite branch June 15, 2018 16:50
@rodrigok rodrigok mentioned this pull request Jun 28, 2018
@q16marvin
Copy link

i have still exakt this problem, admin with permission "add-user-to-any-p-room" cant add users to private rooms where admin is not a member, what do i wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants