mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-06 12:31:33 +01:00
fix: make sure inviter user exists
This commit is contained in:
@@ -38,6 +38,10 @@ module.exports = function (User) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
User.sendInvitationEmail = async function (uid, email, groupsToJoin) {
|
User.sendInvitationEmail = async function (uid, email, groupsToJoin) {
|
||||||
|
if (!uid) {
|
||||||
|
throw new Error('[[error:invalid-uid]]');
|
||||||
|
}
|
||||||
|
|
||||||
const email_exists = await User.getUidByEmail(email);
|
const email_exists = await User.getUidByEmail(email);
|
||||||
if (email_exists) {
|
if (email_exists) {
|
||||||
throw new Error('[[error:email-taken]]');
|
throw new Error('[[error:email-taken]]');
|
||||||
@@ -104,6 +108,11 @@ module.exports = function (User) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function prepareInvitation(uid, email, groupsToJoin) {
|
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 token = utils.generateUUID();
|
||||||
const registerLink = nconf.get('url') + '/register?token=' + token + '&email=' + encodeURIComponent(email);
|
const registerLink = nconf.get('url') + '/register?token=' + token + '&email=' + encodeURIComponent(email);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user