mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-05 15:20:39 +01:00
don't invite an already invited email (#8688)
* don't invite an already invited email * add email-invited translation string
This commit is contained in:
@@ -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.",
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user