Code improvements

pull/9719/head
Rodrigo Nascimento 8 years ago
parent 79873b02d6
commit b7259fce01
No known key found for this signature in database
GPG Key ID: CFCE33B7B01AC335
  1. 2
      packages/rocketchat-lib/server/functions/saveUser.js
  2. 6
      packages/rocketchat-lib/server/functions/setEmail.js
  3. 4
      server/methods/sendConfirmationEmail.js

@ -183,7 +183,7 @@ RocketChat.saveUser = function(userId, userData) {
}
if (userData.email) {
const shouldSendVerificationEmailToUser = !userData.verified;
const shouldSendVerificationEmailToUser = userData.verified !== true;
RocketChat.setEmail(userData._id, userData.email, shouldSendVerificationEmailToUser);
}

@ -1,6 +1,6 @@
import s from 'underscore.string';
RocketChat._setEmail = function(userId, email, shouldSendVerificationEmail) {
RocketChat._setEmail = function(userId, email, shouldSendVerificationEmail = true) {
email = s.trim(email);
if (!userId) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', { function: '_setEmail' });
@ -27,7 +27,9 @@ RocketChat._setEmail = function(userId, email, shouldSendVerificationEmail) {
// Set new email
RocketChat.models.Users.setEmail(user._id, email);
user.email = email;
Meteor.call('sendConfirmationEmail', user.email, shouldSendVerificationEmail);
if (shouldSendVerificationEmail === true) {
Meteor.call('sendConfirmationEmail', user.email);
}
return user;
};

@ -1,11 +1,11 @@
Meteor.methods({
sendConfirmationEmail(email, shouldSendVerificationEmail = true) {
sendConfirmationEmail(email) {
check(email, String);
email = email.trim();
const user = RocketChat.models.Users.findOneByEmailAddress(email);
if (user && shouldSendVerificationEmail) {
if (user) {
if (RocketChat.settings.get('Verification_Customized')) {
const subject = RocketChat.placeholders.replace(RocketChat.settings.get('Verification_Email_Subject') || '');
const html = RocketChat.placeholders.replace(RocketChat.settings.get('Verification_Email') || '');

Loading…
Cancel
Save