mirror of
https://github.com/wekan/wekan.git
synced 2026-01-06 09:38:49 +01:00
Merge pull request #1785 from Akuket/devel
Bugfix : Resending invitation code.
This commit is contained in:
commit
c708877dde
3 changed files with 28 additions and 10 deletions
|
|
@ -101,6 +101,7 @@ BlazeComponent.extendComponent({
|
||||||
// if (!err) {
|
// if (!err) {
|
||||||
// TODO - show more info to user
|
// TODO - show more info to user
|
||||||
// }
|
// }
|
||||||
|
|
||||||
this.setLoading(false);
|
this.setLoading(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -124,20 +124,33 @@ if (Meteor.isServer) {
|
||||||
sendInvitation(emails, boards) {
|
sendInvitation(emails, boards) {
|
||||||
check(emails, [String]);
|
check(emails, [String]);
|
||||||
check(boards, [String]);
|
check(boards, [String]);
|
||||||
|
|
||||||
const user = Users.findOne(Meteor.userId());
|
const user = Users.findOne(Meteor.userId());
|
||||||
if(!user.isAdmin){
|
if(!user.isAdmin){
|
||||||
throw new Meteor.Error('not-allowed');
|
throw new Meteor.Error('not-allowed');
|
||||||
}
|
}
|
||||||
emails.forEach((email) => {
|
emails.forEach((email) => {
|
||||||
if (email && SimpleSchema.RegEx.Email.test(email)) {
|
if (email && SimpleSchema.RegEx.Email.test(email)) {
|
||||||
const code = getRandomNum(100000, 999999);
|
// Checks if the email is already link to an account.
|
||||||
InvitationCodes.insert({code, email, boardsToBeInvited: boards, createdAt: new Date(), authorId: Meteor.userId()}, function(err, _id){
|
const userExist = Users.findOne({email});
|
||||||
if (!err && _id) {
|
if (userExist){
|
||||||
sendInvitationEmail(_id);
|
throw new Meteor.Error('user-exist', `The user with the email ${email} has already an account.`);
|
||||||
} else {
|
}
|
||||||
throw new Meteor.Error('invitation-generated-fail', err.message);
|
// Checks if the email is already link to an invitation.
|
||||||
}
|
const invitation = InvitationCodes.findOne({email});
|
||||||
});
|
if (invitation){
|
||||||
|
InvitationCodes.update(invitation, {$set : {boardsToBeInvited: boards}});
|
||||||
|
sendInvitationEmail(invitation._id);
|
||||||
|
}else {
|
||||||
|
const code = getRandomNum(100000, 999999);
|
||||||
|
InvitationCodes.insert({code, email, boardsToBeInvited: boards, createdAt: new Date(), authorId: Meteor.userId()}, function(err, _id){
|
||||||
|
if (!err && _id) {
|
||||||
|
sendInvitationEmail(_id);
|
||||||
|
} else {
|
||||||
|
throw new Meteor.Error('invitation-generated-fail', err.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -501,9 +501,13 @@ if (Meteor.isServer) {
|
||||||
} else {
|
} else {
|
||||||
user.profile = {icode: options.profile.invitationcode};
|
user.profile = {icode: options.profile.invitationcode};
|
||||||
user.profile.boardView = 'board-view-lists';
|
user.profile.boardView = 'board-view-lists';
|
||||||
}
|
|
||||||
|
|
||||||
return user;
|
// Deletes the invitation code after the user was created successfully.
|
||||||
|
setTimeout(Meteor.bindEnvironment(() => {
|
||||||
|
InvitationCodes.remove({'_id': invitationCode._id});
|
||||||
|
}), 200);
|
||||||
|
return user;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue