fix: make sure inviter user exists

v1.18.x
gasoved 4 years ago committed by Julian Lam
parent a407a51da6
commit 69419571a9

@ -38,6 +38,10 @@ module.exports = function (User) {
};
User.sendInvitationEmail = async function (uid, email, groupsToJoin) {
if (!uid) {
throw new Error('[[error:invalid-uid]]');
}
const email_exists = await User.getUidByEmail(email);
if (email_exists) {
throw new Error('[[error:email-taken]]');
@ -104,6 +108,11 @@ module.exports = function (User) {
}
async function prepareInvitation(uid, email, groupsToJoin) {
const inviterExists = await User.exists(uid);
if (!inviterExists) {
throw new Error('[[error:invalid-uid]]');
}
const token = utils.generateUUID();
const registerLink = nconf.get('url') + '/register?token=' + token + '&email=' + encodeURIComponent(email);

Loading…
Cancel
Save