mirror of
https://gitlab.com/bmcgonag/get_my.git
synced 2026-03-27 00:08:49 +00:00
Added ability for ystem admin to disable registration.
This commit is contained in:
parent
45b78101c8
commit
bc8df48389
10 changed files with 145 additions and 32 deletions
|
|
@ -32,9 +32,11 @@
|
|||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="card-action">
|
||||
<a href="#" id="reg">Register</a>
|
||||
</div>
|
||||
{{#if $eq canReg true}}
|
||||
<div class="card-action">
|
||||
<a href="#" id="reg">Register</a>
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
Template.login.onCreated(function() {
|
||||
import { SysConfig } from '../../../imports/api/systemConfig.js';
|
||||
|
||||
Template.login.onCreated(function() {
|
||||
this.subscribe("SystemConfig");
|
||||
});
|
||||
|
||||
Template.login.onRendered(function() {
|
||||
|
|
@ -9,6 +11,14 @@ Template.login.onRendered(function() {
|
|||
Template.login.helpers({
|
||||
areFilled: function() {
|
||||
return Session.get("filledFields");
|
||||
},
|
||||
canReg: function() {
|
||||
let conf = SysConfig.findOne();
|
||||
if (typeof conf != 'undefined') {
|
||||
return conf.allowReg;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<template name="reg">
|
||||
{{#if $not currentUser}}
|
||||
{{#if $eq allowReg true}}
|
||||
<div id="registrationForm">
|
||||
<div class="container">
|
||||
<h4>Register</h4>
|
||||
|
|
@ -47,5 +48,9 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{else}}
|
||||
<h4>Registration Disabled</h4>
|
||||
<p class="flow-text">The administrator of this system has disabled registration. If you believe you should be allowed to register to use this system, please contact the system administrator for assistance.</p>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
</template>
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
import { SysConfig } from "../../../imports/api/systemConfig.js";
|
||||
|
||||
Template.reg.onCreated(function() {
|
||||
|
||||
this.subscribe("SystemConfig");
|
||||
});
|
||||
|
||||
Template.reg.onRendered(function() {
|
||||
|
|
@ -27,6 +28,14 @@ Template.reg.helpers({
|
|||
},
|
||||
misReq: function() {
|
||||
return Session.get("missingReq");
|
||||
},
|
||||
allowReg: function() {
|
||||
let conf = SysConfig.findOne();
|
||||
if (typeof conf != 'undefined') {
|
||||
return conf.allowReg;
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
<li id="manageLocation" class="collection-item">Location</li>
|
||||
<li id="manageStore" class="collection-item">Store</li>
|
||||
<li id="taskHome" class="collection-item">Tasks</li>
|
||||
<li id="systemAdmin" class="collection-item">System Admin</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
32
client/AdminMgmt/SystemAdmin/systemAdmin.html
Normal file
32
client/AdminMgmt/SystemAdmin/systemAdmin.html
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<template name="systemAdmin">
|
||||
<div class="row">
|
||||
<div class="col s12 m12 l6">
|
||||
<div class="card">
|
||||
<div class="card-content">
|
||||
<h4>System Admin</h4>
|
||||
<div class="row">
|
||||
<div class="col s12 m6 l6">
|
||||
<div class="switch">
|
||||
<label>
|
||||
<input type="checkbox" class="currConfigs" id="allowAdmReg">
|
||||
<span class="lever"></span>
|
||||
Allow Admin Registration
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col s12 m6 l6">
|
||||
<div class="switch">
|
||||
<label>
|
||||
<input type="checkbox" class="currConfigs" id="allowGenReg">
|
||||
<span class="lever"></span>
|
||||
Allow Registration
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{> snackbar}}
|
||||
</template>
|
||||
40
client/AdminMgmt/SystemAdmin/systemAdmin.js
Normal file
40
client/AdminMgmt/SystemAdmin/systemAdmin.js
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import { SysConfig } from '../../../imports/api/systemConfig.js';
|
||||
|
||||
Template.systemAdmin.onCreated(function() {
|
||||
this.subscribe("SystemConfig");
|
||||
});
|
||||
|
||||
Template.systemAdmin.onRendered(function() {
|
||||
this.autorun(() => {
|
||||
let curr = SysConfig.findOne({});
|
||||
if (typeof curr != 'undefined') {
|
||||
$("#allowGenReg").prop('checked', curr.allowReg);
|
||||
$("#allAdmReg").prop('checked', curr.SysAdminReg);
|
||||
} else {
|
||||
console.log(" ---- unable to find current system configuration.");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Template.systemAdmin.helpers({
|
||||
currConfigs: function() {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
Template.systemAdmin.events({
|
||||
'change #allowGenReg, change #allowAdmReg' (evnnt) {
|
||||
let genReg = $("#allowGenReg").prop('checked');
|
||||
let admReg = $("#allowAdmReg").prop('checked');
|
||||
// console.log("General Reg set to: " + genReg);
|
||||
Meteor.call("add.noSysAdminReg", admReg, genReg, function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR updating permission to allow general registration: " + err);
|
||||
showSnackbar("Registration Permission Change Failed.", "red");
|
||||
} else {
|
||||
console.log(" Successfully updated permission to allow general registration.");
|
||||
showSnackbar("Registration Permission Successfully Changed.", "green")
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
@ -12,23 +12,47 @@ SysConfig.allow({
|
|||
});
|
||||
|
||||
Meteor.methods({
|
||||
'add.noSysAdminReg' () {
|
||||
return SysConfig.insert({
|
||||
canReg: false,
|
||||
dateAdded: new Date(),
|
||||
});
|
||||
},
|
||||
'edit.noSysAdminReg' (canReg) {
|
||||
check(canReg, Boolean);
|
||||
'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.');
|
||||
}
|
||||
|
||||
let curr = SysConfig.findOne({});
|
||||
if (typeof curr != 'undefined') {
|
||||
let configId = curr._id;
|
||||
Meteor.call('edit.noSysAdminReg', configId, admReg, genReg, function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR updating sys admin reg: " + err);
|
||||
} else {
|
||||
console.log("Success updating sys admin reg.");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return SysConfig.insert({
|
||||
SysAdminReg: admReg,
|
||||
dateAdded: new Date(),
|
||||
allowReg: genReg,
|
||||
});
|
||||
}
|
||||
},
|
||||
'edit.noSysAdminReg' (configId, canReg, genReg) {
|
||||
check(canReg, Boolean);
|
||||
check(configId, String);
|
||||
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.');
|
||||
}
|
||||
|
||||
return SysConfig.update({ _id: configId }, {
|
||||
$set: {
|
||||
canReg: canReg,
|
||||
SysAdminReg: canReg,
|
||||
allowReg: genReg,
|
||||
dateUpdated: new Date(),
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
@ -12,23 +12,6 @@ UserConfigOptions.allow({
|
|||
});
|
||||
|
||||
Meteor.methods({
|
||||
'add.darkPref' (darkPref) {
|
||||
check(darkPref, Boolean);
|
||||
|
||||
return UserConfigOptions.insert({
|
||||
darkPref: darkPref,
|
||||
owner: this.userId
|
||||
});
|
||||
},
|
||||
'edit.darkPref' (darkPref) {
|
||||
check(darkPref, Boolean);
|
||||
|
||||
return UserConfigOptions.update({ owner: this.userId }, {
|
||||
$set: {
|
||||
darkPref: darkPref
|
||||
}
|
||||
});
|
||||
},
|
||||
'change.userPass' (usersId, password) {
|
||||
check(usersId, String);
|
||||
check(password, String);
|
||||
|
|
|
|||
|
|
@ -123,3 +123,10 @@ FlowRouter.route('/myTasks', {
|
|||
BlazeLayout.render('MainLayout', { main: 'myTasks' });
|
||||
}
|
||||
});
|
||||
|
||||
FlowRouter.route('/systemAdmin', {
|
||||
name: 'systemAdmin',
|
||||
action() {
|
||||
BlazeLayout.render('MainLayout', { main: 'systemAdmin' });
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue