49 lines
1.4 KiB
JavaScript
49 lines
1.4 KiB
JavaScript
import { Meteor } from 'meteor/meteor';
|
|
import { Mongo } from 'meteor/mongo';
|
|
import { check } from 'meteor/check';
|
|
|
|
export const SysConfig = new Mongo.Collection('sysConfig');
|
|
|
|
SysConfig.allow({
|
|
insert: function(userId, doc){
|
|
// if use id exists, allow insert
|
|
return !!userId;
|
|
},
|
|
});
|
|
|
|
Meteor.methods({
|
|
async 'add.noSysAdminReg' (admReg, genReg) {
|
|
check(admReg, Boolean);
|
|
check(genReg, Boolean);
|
|
|
|
if (!this.userId) {
|
|
throw new Meteor.Error('Not able to change registration setting. Make sure you are logged in with valid system administrator credentials.');
|
|
}
|
|
|
|
console.log("Got here...");
|
|
console.log("Adding new.");
|
|
return await SysConfig.upsertAsync({ ruleNo: 1 }, {
|
|
$set: {
|
|
ruleNo: 1,
|
|
SysAdminReg: admReg,
|
|
dateAdded: new Date(),
|
|
allowReg: genReg,
|
|
allowUpdates: true,
|
|
}
|
|
});
|
|
},
|
|
async 'allow.updateInfo' (allowUpdate) {
|
|
check(allowUpdate, Boolean);
|
|
|
|
if (!this.userId) {
|
|
throw new Meteor.Error('Not able to change system update notification settings. Make sure you are logged in with valid system administrator credentials.');
|
|
}
|
|
|
|
return await SysConfig.updateAsync({ ruleNo: 1 }, {
|
|
$set: {
|
|
allowUpdates: allowUpdate,
|
|
}
|
|
});
|
|
},
|
|
});
|
|
|