mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 15:30:13 +01:00
Add a possibility for non admin users who have email on a given domain name (in Admin panel settings) to send an invitation for inscription
This commit is contained in:
parent
344094ec18
commit
b51152fca4
8 changed files with 145 additions and 5 deletions
|
|
@ -88,6 +88,10 @@ Settings.attachSchema(
|
|||
type: String,
|
||||
optional: true,
|
||||
},
|
||||
mailDomaineName: {
|
||||
type: String,
|
||||
optional: true,
|
||||
},
|
||||
createdAt: {
|
||||
type: Date,
|
||||
denyUpdate: true,
|
||||
|
|
@ -290,11 +294,13 @@ if (Meteor.isServer) {
|
|||
|
||||
Meteor.methods({
|
||||
sendInvitation(emails, boards) {
|
||||
let rc = 0;
|
||||
check(emails, [String]);
|
||||
check(boards, [String]);
|
||||
|
||||
const user = Users.findOne(Meteor.userId());
|
||||
if (!user.isAdmin) {
|
||||
rc = -1;
|
||||
throw new Meteor.Error('not-allowed');
|
||||
}
|
||||
emails.forEach(email => {
|
||||
|
|
@ -302,6 +308,7 @@ if (Meteor.isServer) {
|
|||
// Checks if the email is already link to an account.
|
||||
const userExist = Users.findOne({ email });
|
||||
if (userExist) {
|
||||
rc = -1;
|
||||
throw new Meteor.Error(
|
||||
'user-exist',
|
||||
`The user with the email ${email} has already an account.`,
|
||||
|
|
@ -328,6 +335,7 @@ if (Meteor.isServer) {
|
|||
if (!err && _id) {
|
||||
sendInvitationEmail(_id);
|
||||
} else {
|
||||
rc = -1;
|
||||
throw new Meteor.Error(
|
||||
'invitation-generated-fail',
|
||||
err.message,
|
||||
|
|
@ -338,6 +346,7 @@ if (Meteor.isServer) {
|
|||
}
|
||||
}
|
||||
});
|
||||
return rc;
|
||||
},
|
||||
|
||||
sendSMTPTestEmail() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue