Applying last suggestions

pull/7098/head
Luis Fernando do Nascimento 9 years ago
parent 26c255ed55
commit 23219cd686
  1. 6
      client/methods/unsetUserReason.js
  2. 3
      packages/rocketchat-ui-flextab/client/tabs/userInfo.js
  3. 31
      server/lib/accounts.js
  4. 2
      server/methods/setUserActiveStatus.js
  5. 27
      server/methods/unsetUserReason.js

@ -1,6 +0,0 @@
Meteor.methods({
unsetUserReason(userId) {
Meteor.users.update(userId, { $unset: { 'reason' : 1 } });
return true;
}
});

@ -395,9 +395,6 @@ Template.userInfo.events({
if (user) {
return Meteor.call('setUserActiveStatus', user._id, true, function(error, result) {
if (result) {
Meteor.call('unsetUserReason', user._id);
toastr.success(t('User_has_been_activated'));
}
if (error) {

@ -119,23 +119,24 @@ Accounts.onCreateUser(function(options, user = {}) {
}
if (!user.active) {
user.emails.some((email) => {
const destinations = [];
const destinations = [];
let email = {};
RocketChat.models.Roles.findUsersInRole('admin').forEach(function(adminUser) {
RocketChat.models.Roles.findUsersInRole('admin').forEach(function(adminUser) {
if (adminUser.emails[0]) {
destinations.push(`${ adminUser.name }<${ adminUser.emails[0].address }>`);
});
email = {
to: destinations,
from: RocketChat.settings.get('From_Email'),
subject: Accounts.emailTemplates.notifyAdmin.subject(),
html: Accounts.emailTemplates.notifyAdmin.html(options)
};
Meteor.defer(() => {
Email.send(email);
});
}
});
email = {
to: destinations,
from: RocketChat.settings.get('From_Email'),
subject: Accounts.emailTemplates.notifyAdmin.subject(),
html: Accounts.emailTemplates.notifyAdmin.html(options)
};
Meteor.defer(() => {
Email.send(email);
});
}

@ -26,6 +26,8 @@ Meteor.methods({
if (active === false) {
RocketChat.models.Users.unsetLoginTokens(userId);
} else {
RocketChat.models.Users.unsetReason(userId);
}
return true;

@ -1,27 +0,0 @@
Meteor.methods({
unsetUserReason(userId) {
check(userId, String);
if (!Meteor.userId()) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
method: 'unsetUserReason'
});
}
if (RocketChat.authz.hasPermission(Meteor.userId(), 'edit-other-user-active-status') !== true) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', {
method: 'unsetUserReason'
});
}
const user = RocketChat.models.Users.findOneById(userId);
if (user) {
RocketChat.models.Users.unsetReason(userId);
return true;
}
return false;
}
});
Loading…
Cancel
Save