The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Rocket.Chat/server/methods/resetAvatar.js

31 lines
688 B

Meteor.methods({
8 years ago
resetAvatar() {
if (!Meteor.userId()) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
method: 'resetAvatar'
});
}
if (!RocketChat.settings.get('Accounts_AllowUserAvatarChange')) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', {
method: 'resetAvatar'
});
}
const user = Meteor.user();
FileUpload.getStore('Avatars').deleteByName(user.username);
8 years ago
RocketChat.models.Users.unsetAvatarOrigin(user._id);
RocketChat.Notifications.notifyLogged('updateAvatar', {
username: user.username
});
}
});
DDPRateLimiter.addRule({
8 years ago
type: 'method',
name: 'resetAvatar',
userId() {
return true;
}
}, 1, 60000);