Skip to content

Node.js based forum software built for the modern web

don't invite an already invited email (#8688)

Timothy Fikef85fe7faffc2
diff --git a/public/language/en-GB/error.json b/public/language/en-GB/error.json
index 7d02231e02..206e7bbf26 100644
--- a/public/language/en-GB/error.json
+++ b/public/language/en-GB/error.json
@@ -31,6 +31,7 @@
"username-taken": "Username taken",
"email-taken": "Email taken",
+ "email-invited": "Email was already invited",
"email-not-confirmed": "You are unable to post until your email is confirmed, please click here to confirm your email.",
"email-not-confirmed-chat": "You are unable to chat until your email is confirmed, please click here to confirm your email.",
"email-not-confirmed-email-sent": "Your email has not been confirmed yet, please check your inbox for the confirmation email. You won't be able to post or chat until your email is confirmed.",
diff --git a/src/user/invite.js b/src/user/invite.js
index 2b0b217cd2..82471d8b28 100644
--- a/src/user/invite.js
+++ b/src/user/invite.js
@@ -43,10 +43,16 @@ module.exports = function (User) {
const expireDays = meta.config.inviteExpiration;
const expireIn = expireDays * 86400000;
- const exists = await User.getUidByEmail(email);
- if (exists) {
+ const email_exists = await User.getUidByEmail(email);
+ if (email_exists) {
throw new Error('[[error:email-taken]]');
}
+
+ const invitation_exists = await db.exists('invitation:email:' + email);
+ if (invitation_exists) {
+ throw new Error('[[error:email-invited]]');
+ }
+
await db.setAdd('invitation:uid:' + uid, email);
await db.setAdd('invitation:uids', uid);
await db.set('invitation:email:' + email, token);