add currentSetting to ReactiveCache

This commit is contained in:
Martin Filser 2022-12-13 23:20:04 +01:00
parent c6ee58ef88
commit b7dbeba7de
13 changed files with 59 additions and 55 deletions

View file

@ -1,3 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import { TAPi18n } from '/imports/i18n';
//var nodemailer = require('nodemailer');
@ -167,7 +168,7 @@ Settings.allow({
if (Meteor.isServer) {
Meteor.startup(() => {
Settings._collection.createIndex({ modifiedAt: -1 });
const setting = Settings.findOne({});
const setting = ReactiveCache.getCurrentSetting();
if (!setting) {
const now = new Date();
const domain = process.env.ROOT_URL.match(
@ -193,7 +194,7 @@ if (Meteor.isServer) {
}
if (isSandstorm) {
// At Sandstorm, Admin Panel has SMTP settings
const newSetting = Settings.findOne();
const newSetting = ReactiveCache.getCurrentSetting();
if (!process.env.MAIL_URL && newSetting.mailUrl())
process.env.MAIL_URL = newSetting.mailUrl();
Accounts.emailTemplates.from = process.env.MAIL_FROM
@ -301,7 +302,7 @@ if (Meteor.isServer) {
}
function isNonAdminAllowedToSendMail(currentUser){
const currSett = Settings.findOne({});
const currSett = ReactiveCache.getCurrentSetting();
let isAllowed = false;
if(currSett && currSett != undefined && currSett.disableRegistration && currSett.mailDomainName !== undefined && currSett.mailDomainName != ""){
for(let i = 0; i < currentUser.emails.length; i++) {
@ -449,7 +450,7 @@ if (Meteor.isServer) {
},
getCustomUI() {
const setting = Settings.findOne({});
const setting = ReactiveCache.getCurrentSetting();
if (!setting.productName) {
return {
productName: '',
@ -462,7 +463,7 @@ if (Meteor.isServer) {
},
isDisableRegistration() {
const setting = Settings.findOne({});
const setting = ReactiveCache.getCurrentSetting();
if (setting.disableRegistration === true) {
return true;
} else {
@ -471,7 +472,7 @@ if (Meteor.isServer) {
},
isDisableForgotPassword() {
const setting = Settings.findOne({});
const setting = ReactiveCache.getCurrentSetting();
if (setting.disableForgotPassword === true) {
return true;
} else {

View file

@ -1,4 +1,4 @@
//var nodemailer = require('nodemailer');
import { ReactiveCache } from '/imports/reactiveCache';
import { SyncedCron } from 'meteor/percolate:synced-cron';
import { TAPi18n } from '/imports/i18n';
import ImpersonatedUsers from './impersonatedUsers';
@ -1425,11 +1425,7 @@ if (Meteor.isServer) {
throw new Meteor.Error('error-user-notAllowSelf');
} else {
if (posAt <= 0) throw new Meteor.Error('error-user-doesNotExist');
if (
Settings.findOne({
disableRegistration: true,
})
) {
if (ReactiveCache.getCurrentSetting().disableRegistration) {
throw new Meteor.Error('error-user-notCreated');
}
// Set in lowercase email before creating account
@ -1667,7 +1663,7 @@ if (Meteor.isServer) {
return user;
}
const disableRegistration = Settings.findOne().disableRegistration;
const disableRegistration = ReactiveCache.getCurrentSetting().disableRegistration;
// If this is the first Authentication by the ldap and self registration disabled
if (disableRegistration && options && options.ldap) {
user.authenticationMethod = 'ldap';
@ -1972,7 +1968,7 @@ if (Meteor.isServer) {
}
//invite user to corresponding boards
const disableRegistration = Settings.findOne().disableRegistration;
const disableRegistration = Utils.getCurrentSetting().disableRegistration;
// If ldap, bypass the inviation code if the self registration isn't allowed.
// TODO : pay attention if ldap field in the user model change to another content ex : ldap field to connection_type
if (doc.authenticationMethod !== 'ldap' && disableRegistration) {