Fix bug regarding non admin users who have an email on a given domain name (field in Admin panel settings) and that can't invite new users for a registration

This commit is contained in:
Emile NDAGIJIMANA 2021-12-13 19:14:52 +01:00
parent 01cd1c0fdc
commit 2f69501c14

View file

@ -274,6 +274,20 @@ if (Meteor.isServer) {
}
}
function isNonAdminAllowedToSendMail(currentUser){
const currSett = Settings.findOne({});
let isAllowed = false;
if(currSett && currSett != undefined && currSett.disableRegistration && currSett.mailDomainName !== undefined && currSett.mailDomainName != ""){
for(let i = 0; i < currentUser.emails.length; i++) {
if(currentUser.emails[i].address.endsWith(currSett.mailDomainName)){
isAllowed = true;
break;
}
}
}
return isAllowed;
}
function isLdapEnabled() {
return (
process.env.LDAP_ENABLE === 'true' || process.env.LDAP_ENABLE === true
@ -304,7 +318,7 @@ if (Meteor.isServer) {
check(boards, [String]);
const user = Users.findOne(Meteor.userId());
if (!user.isAdmin) {
if (!user.isAdmin && !isNonAdminAllowedToSendMail(user)) {
rc = -1;
throw new Meteor.Error('not-allowed');
}