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/afterVerifyEmail.js

24 lines
565 B

import { Meteor } from 'meteor/meteor';
import _ from 'underscore';
Meteor.methods({
afterVerifyEmail() {
const userId = Meteor.userId();
if (!userId) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
method: 'afterVerifyEmail',
});
}
const user = RocketChat.models.Users.findOneById(userId);
const verifiedEmail = _.find(user.emails, (email) => email.verified);
if (verifiedEmail) {
RocketChat.models.Roles.addUserRoles(user._id, 'user');
RocketChat.models.Roles.removeUserRoles(user._id, 'anonymous');
}
},
});