Add the 'users.resetAvatar' endpoint, which resets the avatar back to the initals version

pull/6616/head
Bradley Hilton 8 years ago
parent 9323473b1d
commit 6e47cd42a3
No known key found for this signature in database
GPG Key ID: 0666B2C24C43C358
  1. 16
      packages/rocketchat-api/server/v1/users.js

@ -169,6 +169,22 @@ RocketChat.API.v1.addRoute('users.register', { authRequired: false }, {
}
});
RocketChat.API.v1.addRoute('users.resetAvatar', { authRequired: true }, {
post() {
const user = this.getUserFromParams();
if (user._id === this.userId) {
Meteor.runAsUser(this.userId, () => Meteor.call('resetAvatar'));
} else if (RocketChat.authz.hasPermission(this.userId, 'edit-other-user-info')) {
Meteor.runAsUser(user._id, () => Meteor.call('resetAvatar'));
} else {
return RocketChat.API.v1.unauthorized();
}
return RocketChat.API.v1.success();
}
});
//TODO: Make this route work with support for usernames
RocketChat.API.v1.addRoute('users.setAvatar', { authRequired: true }, {
post() {

Loading…
Cancel
Save