-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Conversation
…nother user even with necessary permission
users.setAvatar
endpoint wasn't allowing update the avatar of other users even with correct permissions
userFromFormData = RocketChat.models.Users.findOneByUsername(fields.username); | ||
} | ||
return userFromFormData; | ||
}; |
There was a problem hiding this comment.
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 }); | ||
}); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at line 250
Any updates on this, why is it on hold? |
Closes #11334