Skip to content

Commit

Permalink
Merge pull request #6616 from RocketChat/remove-avatar-rest-api
Browse files Browse the repository at this point in the history
[NEW] 'users.resetAvatar' rest api endpoint
  • Loading branch information
engelgabriel authored Apr 6, 2017
2 parents 9323473 + 6e47cd4 commit b9fe09b
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 b9fe09b

Please sign in to comment.