Skip to content

Commit

Permalink
Add the 'users.resetAvatar' endpoint, which resets the avatar back to…
Browse files Browse the repository at this point in the history
… the initals version
  • Loading branch information
graywolf336 committed Apr 6, 2017
1 parent 9323473 commit 6e47cd4
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/rocketchat-api/server/v1/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 6e47cd4

Please sign in to comment.