mirror of
https://github.com/wekan/wekan.git
synced 2025-04-23 13:37:09 -04:00
Merge branch 'invtn-bug-fix' of https://github.com/lkisme/wekan into lkisme-invtn-bug-fix
This commit is contained in:
commit
b54e0c8b4f
4 changed files with 19 additions and 12 deletions
|
@ -1,6 +1,6 @@
|
|||
Template.invitationCode.onRendered(() => {
|
||||
const disableRegistration = Settings.findOne().disableRegistration;
|
||||
if(!disableRegistration){
|
||||
const setting = Settings.findOne();
|
||||
if (!setting || !setting.disableRegistration) {
|
||||
$('#invitationcode').hide();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -13,7 +13,6 @@ AccountsTemplates.addFields([{
|
|||
displayName: 'Invitation Code',
|
||||
required: false,
|
||||
minLength: 6,
|
||||
errStr: 'Invitation code doesn\'t exist',
|
||||
template: 'invitationCode',
|
||||
}]);
|
||||
|
||||
|
@ -69,4 +68,3 @@ if (Meteor.isServer) {
|
|||
};
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -104,6 +104,7 @@ if (Meteor.isServer) {
|
|||
text: TAPi18n.__('email-invite-register-text', params, lang),
|
||||
});
|
||||
} catch (e) {
|
||||
InvitationCodes.remove(_id);
|
||||
throw new Meteor.Error('email-fail', e.message);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,6 +91,10 @@ Users.attachSchema(new SimpleSchema({
|
|||
type: [String],
|
||||
optional: true,
|
||||
},
|
||||
'profile.icode': {
|
||||
type: String,
|
||||
optional: true,
|
||||
},
|
||||
services: {
|
||||
type: Object,
|
||||
optional: true,
|
||||
|
@ -401,11 +405,12 @@ if (Meteor.isServer) {
|
|||
return user;
|
||||
}
|
||||
|
||||
const iCode = options.profile.invitationcode | '';
|
||||
|
||||
const invitationCode = InvitationCodes.findOne({code: iCode, valid:true});
|
||||
if (!options || !options.profile) {
|
||||
throw new Meteor.Error('error-invitation-code-blank', 'The invitation code is required');
|
||||
}
|
||||
const invitationCode = InvitationCodes.findOne({code: options.profile.invitationcode, email: options.email, valid: true});
|
||||
if (!invitationCode) {
|
||||
throw new Meteor.Error('error-invitation-code-not-exist');
|
||||
throw new Meteor.Error('error-invitation-code-not-exist', 'The invitation code doesn\'t exist');
|
||||
}else{
|
||||
user.profile = {icode: options.profile.invitationcode};
|
||||
}
|
||||
|
@ -487,16 +492,19 @@ if (Meteor.isServer) {
|
|||
//invite user to corresponding boards
|
||||
const disableRegistration = Settings.findOne().disableRegistration;
|
||||
if (disableRegistration) {
|
||||
const user = Users.findOne(doc._id);
|
||||
const invitationCode = InvitationCodes.findOne({code: user.profile.icode, valid:true});
|
||||
const invitationCode = InvitationCodes.findOne({code: doc.profile.icode, valid:true});
|
||||
if (!invitationCode) {
|
||||
throw new Meteor.Error('error-user-notCreated');
|
||||
throw new Meteor.Error('error-invitation-code-not-exist');
|
||||
}else{
|
||||
invitationCode.boardsToBeInvited.forEach((boardId) => {
|
||||
const board = Boards.findOne(boardId);
|
||||
board.addMember(doc._id);
|
||||
});
|
||||
user.profile = {invitedBoards: invitationCode.boardsToBeInvited};
|
||||
if (!doc.profile) {
|
||||
doc.profile = {};
|
||||
}
|
||||
doc.profile.invitedBoards = invitationCode.boardsToBeInvited;
|
||||
Users.update(doc._id, {$set:{profile: doc.profile}});
|
||||
InvitationCodes.update(invitationCode._id, {$set: {valid:false}});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue