2025-12-06 15:44:43 -06:00
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 ( {
2026-02-03 16:03:34 -06:00
async 'add.noSysAdminReg' ( admReg , genReg ) {
2025-12-06 15:44:43 -06:00
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." ) ;
2026-02-03 16:03:34 -06:00
return await SysConfig . upsertAsync ( { ruleNo : 1 } , {
2025-12-06 15:44:43 -06:00
$set : {
ruleNo : 1 ,
SysAdminReg : admReg ,
dateAdded : new Date ( ) ,
allowReg : genReg ,
allowUpdates : true ,
}
} ) ;
} ,
2026-02-03 16:03:34 -06:00
async 'allow.updateInfo' ( allowUpdate ) {
2025-12-06 15:44:43 -06:00
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.' ) ;
}
2026-02-03 16:03:34 -06:00
return await SysConfig . updateAsync ( { ruleNo : 1 } , {
2025-12-06 15:44:43 -06:00
$set : {
allowUpdates : allowUpdate ,
}
} ) ;
} ,
} ) ;