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] REST users.setAvatar endpoint wasn't allowing update the avatar of other users even with correct permissions #11431

Merged
merged 7 commits into from
Oct 20, 2018

Conversation

MarcosSpessatto
Copy link
Member

Closes #11334

@MarcosSpessatto MarcosSpessatto added this to the 0.67.0 milestone Jul 11, 2018
@MarcosSpessatto MarcosSpessatto self-assigned this Jul 11, 2018
@engelgabriel engelgabriel temporarily deployed to rocket-chat-pr-11431 July 11, 2018 22:14 Inactive
@theorenck theorenck modified the milestones: 0.67.0, 0.68.0 Jul 19, 2018
@theorenck theorenck modified the milestones: 0.68.0, Short-term Jul 31, 2018
@MarcosSpessatto MarcosSpessatto modified the milestones: Short-term, 0.69.0 Aug 9, 2018
@engelgabriel engelgabriel temporarily deployed to rocket-chat-pr-11431 August 17, 2018 18:37 Inactive
@rodrigok rodrigok changed the title [FIX]Fix REST users.setAvatar that did not allow to update the avatar of another user even with necessary permission [FIX] REST users.setAvatar endpoint wasn't allowing update the avatar of other users even with correct permissions Aug 20, 2018
userFromFormData = RocketChat.models.Users.findOneByUsername(fields.username);
}
return userFromFormData;
};
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion:

const getUserFromFormData = (fields) => {
	if (fields.userId) {
		return RocketChat.models.Users.findOneById(fields.userId, {_id: 1});
	}
	if (fields.username) {
		return RocketChat.models.Users.findOneByUsername(fields.username, {_id: 1});
	}
};

}));
busboy.on('field', (fieldname, val) => {
fields = Object.assign(fields, { [fieldname]: val });
});
Copy link
Member

Choose a reason for hiding this comment

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

Why not?:

busboy.on('field', (fieldname, val) => {
	fields[fieldname] = val;
});

const imageData = [];
file.on('data', Meteor.bindEnvironment((data) => {
imageData.push(data);
}));

file.on('end', Meteor.bindEnvironment(() => {
const sentTheUserByFormData = fields.userId || fields.username;
if (sentTheUserByFormData) {
user = getUserFromFormData(fields);
Copy link
Member

Choose a reason for hiding this comment

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

Where are we checking the permissions to change the other user's avatar?

Copy link
Member

Choose a reason for hiding this comment

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

@GiverOfGifts
Copy link

Any updates on this, why is it on hold?

@MarcosSpessatto MarcosSpessatto modified the milestones: 0.69.0, 0.71.0 Oct 10, 2018
@sampaiodiego sampaiodiego requested a deployment to rocket-chat-pr-11431 October 20, 2018 20:22 Abandoned
@sampaiodiego sampaiodiego merged commit cffa9ed into develop Oct 20, 2018
@sampaiodiego sampaiodiego deleted the fix-rest-set-avatar branch October 20, 2018 20:44
@sampaiodiego sampaiodiego mentioned this pull request Oct 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants