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/apps/meteor/server/methods/sendConfirmationEmail.ts

33 lines
918 B

import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import { Accounts } from 'meteor/accounts-base';
import type { ServerMethods } from '@rocket.chat/ui-contexts';
import { Users } from '@rocket.chat/models';
import { methodDeprecationLogger } from '../../app/lib/server/lib/deprecationWarningLogger';
Meteor.methods<ServerMethods>({
async sendConfirmationEmail(to) {
check(to, String);
methodDeprecationLogger.method('sendConfirmationEmail', '7.0.0');
const email = to.trim();
const user = await Users.findOneByEmailAddress(email, { projection: { _id: 1 } });
if (!user) {
return false;
}
try {
Accounts.sendVerificationEmail(user._id, email);
return true;
} catch (error: any) {
throw new Meteor.Error('error-email-send-failed', `Error trying to send email: ${error.message}`, {
method: 'registerUser',
message: error.message,
});
}
},
});