mirror of
https://gitlab.com/bmcgonag/get_my.git
synced 2026-03-27 00:08:49 +00:00
My big initial commit to this repo and project.
This commit is contained in:
parent
750811a81f
commit
8636f8cf9b
2433 changed files with 199488 additions and 1042 deletions
|
|
@ -1,9 +1,8 @@
|
|||
<template name="teacherLogin">
|
||||
<template name="login">
|
||||
{{#if $not currentUser}}
|
||||
<div id="signInForm">
|
||||
<div class="container">
|
||||
<h3>Teacher Login</h3>
|
||||
<p>It is very important to the safety of all children that you do not share your login credentials with anyone.</p>
|
||||
<h4>Login</h4>
|
||||
<div class="card">
|
||||
<div class="card-content">
|
||||
<form class="login">
|
||||
|
|
@ -34,7 +33,7 @@
|
|||
</form>
|
||||
</div>
|
||||
<div class="card-action">
|
||||
<a href="#" id="teacherReg">Register</a>
|
||||
<a href="#" id="reg">Register</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,18 +1,18 @@
|
|||
Template.parentLogin.onCreated(function() {
|
||||
Template.login.onCreated(function() {
|
||||
|
||||
});
|
||||
|
||||
Template.parentLogin.onRendered(function() {
|
||||
Template.login.onRendered(function() {
|
||||
|
||||
});
|
||||
|
||||
Template.parentLogin.helpers({
|
||||
Template.login.helpers({
|
||||
areFilled: function() {
|
||||
return Session.get("filledFields");
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
Template.parentLogin.events({
|
||||
Template.login.events({
|
||||
'click #logmein' (event) {
|
||||
event.preventDefault();
|
||||
console.log("clicked login");
|
||||
|
|
@ -26,8 +26,8 @@ Template.parentLogin.events({
|
|||
Meteor.loginWithPassword(email, pass);
|
||||
}
|
||||
},
|
||||
'click #parentReg' (event) {
|
||||
'click #reg' (event) {
|
||||
event.preventDefault();
|
||||
FlowRouter.go('/parentReg');
|
||||
FlowRouter.go('/reg');
|
||||
},
|
||||
});
|
||||
|
|
@ -1,9 +1,8 @@
|
|||
<template name="teacherRegistration">
|
||||
<template name="reg">
|
||||
{{#if $not currentUser}}
|
||||
<div id="registrationForm">
|
||||
<div class="container">
|
||||
<h3>Teacher Registration</h3>
|
||||
<p>It is very important to the safety of all children that you do not share your login credentials with anyone.</p>
|
||||
<h4>Register</h4>
|
||||
<div class="row">
|
||||
<div class="col s12">
|
||||
<div class="card">
|
||||
|
|
@ -14,10 +13,6 @@
|
|||
<input type="text" name="name" class="name {{#if $eq misName true}}red lighten-3{{/if}}" id="name" />
|
||||
<label for="name">Your Full Name *</label>
|
||||
</div>
|
||||
<div class="col s12 input-field">
|
||||
<input type="tel" name="phone" class="phone {{#if $eq misPhone true}}red lighten-3{{/if}}" id="phone" />
|
||||
<label for="phone">Best Phone Number *</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col s12 input-field">
|
||||
|
|
@ -45,7 +40,7 @@
|
|||
</form>
|
||||
</div>
|
||||
<div class="card-action">
|
||||
<a href="#" id="teachLogin">Sign In</a>
|
||||
<a href="#" id="login">Sign In</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
Template.teacherRegistration.onCreated(function() {
|
||||
Template.reg.onCreated(function() {
|
||||
|
||||
});
|
||||
|
||||
Template.teacherRegistration.onRendered(function() {
|
||||
Template.reg.onRendered(function() {
|
||||
Session.set("canreg", false);
|
||||
Session.set("missingReq", false);
|
||||
Session.set("missingName", false);
|
||||
|
|
@ -12,16 +12,13 @@ Template.teacherRegistration.onRendered(function() {
|
|||
Session.set("missingPassword", false);
|
||||
});
|
||||
|
||||
Template.teacherRegistration.helpers({
|
||||
Template.reg.helpers({
|
||||
canReg: function() {
|
||||
return Session.get("canreg");
|
||||
},
|
||||
misName: function() {
|
||||
return Session.get("missingName");
|
||||
},
|
||||
misPhone: function() {
|
||||
return Session.get("missingPhone");
|
||||
},
|
||||
misEmail: function() {
|
||||
return Session.get("missingEmail");
|
||||
},
|
||||
|
|
@ -33,7 +30,7 @@ Template.teacherRegistration.helpers({
|
|||
}
|
||||
});
|
||||
|
||||
Template.teacherRegistration.events({
|
||||
Template.reg.events({
|
||||
'click #registerMe' (event) {
|
||||
event.preventDefault();
|
||||
if (Session.get("canreg") == false) {
|
||||
|
|
@ -41,7 +38,6 @@ Template.teacherRegistration.events({
|
|||
} else {
|
||||
// console.log("Clicked");
|
||||
let missingName = false;
|
||||
let missingPhone = false;
|
||||
let missingEmail = false;
|
||||
let missingPassword = false;
|
||||
|
||||
|
|
@ -55,11 +51,6 @@ Template.teacherRegistration.events({
|
|||
Session.set("missingName", true);
|
||||
}
|
||||
|
||||
if (phone == "" || phone == null) {
|
||||
missingPhone = true;
|
||||
Session.set("missingPhone", true);
|
||||
}
|
||||
|
||||
if (email == "" || email == null) {
|
||||
missingEmail = true;
|
||||
Session.set("missingEmail", true);
|
||||
|
|
@ -72,7 +63,7 @@ Template.teacherRegistration.events({
|
|||
|
||||
let userId;
|
||||
|
||||
if (missingName == true || missingPhone == true || missingEmail == true || missingPassword == true) {
|
||||
if (missingName == true || missingEmail == true || missingPassword == true) {
|
||||
Session.set("missingReq", true);
|
||||
} else {
|
||||
Session.set("missingReq", false);
|
||||
|
|
@ -81,13 +72,12 @@ Template.teacherRegistration.events({
|
|||
password: password,
|
||||
profile: {
|
||||
fullname: name,
|
||||
phone: phone,
|
||||
}
|
||||
});
|
||||
|
||||
let userId = Meteor.userId();
|
||||
console.log("User ID: " + userId);
|
||||
Meteor.call("addToRole", "teacher", function(err, result) {
|
||||
Meteor.call("addToRole", "user", function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR: ROLES - Error adding user to role: " + err);
|
||||
} else {
|
||||
|
|
@ -120,8 +110,8 @@ Template.teacherRegistration.events({
|
|||
Session.set("missingEmail", false);
|
||||
}
|
||||
},
|
||||
'click #teachLogin' (event) {
|
||||
'click #login' (event) {
|
||||
event.preventDefault();
|
||||
FlowRouter.go('/teachlogin');
|
||||
FlowRouter.go('/login');
|
||||
},
|
||||
});
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
<template name="parentLogin">
|
||||
{{#if $not currentUser}}
|
||||
<div id="signInForm">
|
||||
<div class="container">
|
||||
<h3>Parent / Guardian Login</h3>
|
||||
<p>It is very important to the safety of all children that you do not share your login credentials with anyone.</p>
|
||||
<div class="card">
|
||||
<div class="card-content">
|
||||
<form class="login">
|
||||
<div class="row">
|
||||
<div class="col s12 input-field">
|
||||
<input type="email" name="email" id="email" class="email {{#if $eq misEmail true}}red lighten-3{{/if}}" />
|
||||
<label for="email">Email *</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col s12 input-field">
|
||||
<input type="password" name="password" id="password" class="password {{#if $eq misPass true}}red lighten-3{{/if}}" />
|
||||
<label for="password">Password *</label>
|
||||
</div>
|
||||
</div>
|
||||
{{#if $eq areFilled false}}
|
||||
<div class="row">
|
||||
<div class="col s12 red lighten-3 white-text">
|
||||
<span>You must fill all fields to login.</span>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
<div class="row">
|
||||
<div class="col s12">
|
||||
<a id="logmein" class="waves-effect waves-light btn logmein green darken-1">Log In</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="card-action">
|
||||
<a href="#" id="parentReg">Register</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
</template>
|
||||
|
|
@ -1,123 +0,0 @@
|
|||
|
||||
Template.parentsRegistration.onRendered(function() {
|
||||
Session.set("canreg", false);
|
||||
Session.set("missingReq", false);
|
||||
Session.set("missingName", false);
|
||||
Session.set("missingPhone", false);
|
||||
Session.set("missingEmail", false);
|
||||
Session.set("missingPassword", false);
|
||||
});
|
||||
|
||||
Template.parentsRegistration.helpers({
|
||||
canReg: function() {
|
||||
return Session.get("canreg");
|
||||
},
|
||||
misName: function() {
|
||||
return Session.get("missingName");
|
||||
},
|
||||
misPhone: function() {
|
||||
return Session.get("missingPhone");
|
||||
},
|
||||
misEmail: function() {
|
||||
return Session.get("missingEmail");
|
||||
},
|
||||
misPass: function() {
|
||||
return Session.get("missingPassword");
|
||||
},
|
||||
misReq: function() {
|
||||
return Session.get("missingReq");
|
||||
}
|
||||
});
|
||||
|
||||
Template.parentsRegistration.events({
|
||||
'click #registerMe' (event) {
|
||||
event.preventDefault();
|
||||
if (Session.get("canreg") == false) {
|
||||
console.log("reg disabled.");
|
||||
} else {
|
||||
console.log("Clicked");
|
||||
let missingName = false;
|
||||
let missingPhone = false;
|
||||
let missingEmail = false;
|
||||
let missingPassword = false;
|
||||
|
||||
let email = $("#email").val();
|
||||
let password = $("#password").val();
|
||||
let name = $("#name").val();
|
||||
let phone = $("#phone").val();
|
||||
|
||||
if (name == "" || name == null) {
|
||||
missingName = true;
|
||||
Session.set("missingName", true);
|
||||
}
|
||||
|
||||
if (phone == "" || phone == null) {
|
||||
missingPhone = true;
|
||||
Session.set("missingPhone", true);
|
||||
}
|
||||
|
||||
if (email == "" || email == null) {
|
||||
missingEmail = true;
|
||||
Session.set("missingEmail", true);
|
||||
}
|
||||
|
||||
if (password == "" || password == null) {
|
||||
missingPassword = true;
|
||||
Session.set("missingPassword", true);
|
||||
}
|
||||
|
||||
let userId;
|
||||
|
||||
if (missingName == true || missingPhone == true || missingEmail == true || missingPassword == true) {
|
||||
Session.set("missingReq", true);
|
||||
} else {
|
||||
Session.set("missingReq", false);
|
||||
Accounts.createUser({
|
||||
email: email,
|
||||
password: password,
|
||||
profile: {
|
||||
fullname: name,
|
||||
phone: phone,
|
||||
}
|
||||
});
|
||||
|
||||
let userId = Meteor.userId();
|
||||
console.log("User ID: " + userId);
|
||||
Meteor.call("addToRole", "parent", function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR: ROLES - Error adding user to role: " + err);
|
||||
} else {
|
||||
// console.log("User should be added to role - parent.");
|
||||
FlowRouter.go('/dashboard');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
'keyup #passwordConfirm' (event) {
|
||||
let pwd = $("#password").val();
|
||||
let pwdconf = $("#passwordConfirm").val();
|
||||
|
||||
if (pwd == pwdconf) {
|
||||
// console.log("passwords match");
|
||||
Session.set("canreg", true);
|
||||
} else {
|
||||
// console.log("passwords don't match");
|
||||
Session.set("canreg", false);
|
||||
}
|
||||
},
|
||||
'change #email' (event) {
|
||||
let email = $("#email").val();
|
||||
var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
|
||||
let isEmail = regex.test(email);
|
||||
if (isEmail == false) {
|
||||
Session.set("missingEmail", true);
|
||||
} else {
|
||||
Session.set("missingEmail", false);
|
||||
}
|
||||
},
|
||||
'click #parguarlogin' (event) {
|
||||
event.preventDefault();
|
||||
FlowRouter.go('/parguarlogin');
|
||||
},
|
||||
});
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
<template name="parentsRegistration">
|
||||
{{#if $not currentUser}}
|
||||
<div id="registrationForm">
|
||||
<div class="container">
|
||||
<h3>Parent / Guardian Registration</h3>
|
||||
<p>It is very important to the safety of all children that you do not share your login credentials with anyone.</p>
|
||||
<div class="row">
|
||||
<div class="col s12">
|
||||
<div class="card">
|
||||
<div class="card-content">
|
||||
<form class="register">
|
||||
<div class="row">
|
||||
<div class="col s12 input-field">
|
||||
<input type="text" name="name" class="name {{#if $eq misName true}}red lighten-3{{/if}}" id="name" />
|
||||
<label for="name">Your Full Name *</label>
|
||||
</div>
|
||||
<div class="col s12 input-field">
|
||||
<input type="tel" name="phone" class="phone {{#if $eq misPhone true}}red lighten-3{{/if}}" id="phone" />
|
||||
<label for="phone">Best Phone Number *</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col s12 input-field">
|
||||
<input type="email" name="email" id="email" class="email {{#if $eq misEmail true}}red lighten-3{{/if}}" />
|
||||
<label for="email">Email *</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col s12 input-field">
|
||||
<input type="password" name="password" id="password" class="password {{#if $eq misPass true}}red lighten-3{{/if}}" />
|
||||
<label for="password">Password *</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col s12 input-field {{#if $eq canReg false}}orange lighten-1{{/if}}">
|
||||
<input type="password" name="passwordConfirm" id="passwordConfirm" class="passwordConfirm" />
|
||||
<label for="passwordConfirm">Confirm Password *</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col s12">
|
||||
<a id="registerMe" class="waves-effect waves-light btn registerMe {{#if $eq canReg false}}grey{{else}}green darken-1{{/if}}">Register</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="card-action">
|
||||
<a href="#" id="parguarlogin">Sign In</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
</template>
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
<template name="systemAdminLogin">
|
||||
{{#if $not currentUser}}
|
||||
<div id="signInForm">
|
||||
<div class="container">
|
||||
<h3>System Administrator Login</h3>
|
||||
<p>It is very important to the safety of all children that you do not share your login credentials with anyone.</p>
|
||||
<div class="card">
|
||||
<div class="card-content">
|
||||
<form class="login">
|
||||
<div class="row">
|
||||
<div class="col s12 input-field">
|
||||
<input type="email" name="email" id="email" class="email {{#if $eq misEmail true}}red lighten-3{{/if}}" />
|
||||
<label for="email">Email *</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col s12 input-field">
|
||||
<input type="password" name="password" id="password" class="password {{#if $eq misPass true}}red lighten-3{{/if}}" />
|
||||
<label for="password">Password *</label>
|
||||
</div>
|
||||
</div>
|
||||
{{#if $eq areFilled false}}
|
||||
<div class="row">
|
||||
<div class="col s12 red lighten-3 white-text">
|
||||
<span>You must fill all fields to login.</span>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#if $eq loginError true}}
|
||||
<div class="row">
|
||||
<div class="col s12 red lighten-2 white-text">
|
||||
<span>Username or Password is incorrect. Please check your credentials and try again, or click 'Register' to create a new account.</span>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
<div class="row">
|
||||
<div class="col s12">
|
||||
<a id="logmein" class="waves-effect waves-light btn logmein green darken-1">Log In</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="card-action">
|
||||
<a href="#" id="sysAdminReg">Register</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
</template>
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
Template.systemAdminLogin.onCreated(function() {
|
||||
|
||||
});
|
||||
|
||||
Template.systemAdminLogin.onRendered(function() {
|
||||
|
||||
});
|
||||
|
||||
Template.systemAdminLogin.helpers({
|
||||
areFilled: function() {
|
||||
return Session.get("filledFields");
|
||||
},
|
||||
loginError: function() {
|
||||
return Session.get("loginError");
|
||||
},
|
||||
});
|
||||
|
||||
Template.systemAdminLogin.events({
|
||||
'click #logmein' (event) {
|
||||
event.preventDefault();
|
||||
console.log("clicked login");
|
||||
let email = $("#email").val();
|
||||
let pass = $("#password").val();
|
||||
|
||||
if (email == null || email == "" || pass == "" || pass == null) {
|
||||
Session.set("filledFields", false);
|
||||
return;
|
||||
} else {
|
||||
return Meteor.loginWithPassword(email, pass, function(err, result) {
|
||||
if (err) {
|
||||
console.log("Error logging in: " + err);
|
||||
Session.set("loginError", true);
|
||||
} else {
|
||||
console.log("login result: " + result);
|
||||
Session.set("loginError", false);
|
||||
FlowRouter.go('/dashboard');
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
'click #sysAdminReg' (event) {
|
||||
event.preventDefault();
|
||||
FlowRouter.go('/systemAdminReg');
|
||||
},
|
||||
});
|
||||
|
|
@ -1,69 +0,0 @@
|
|||
<template name="systemAdminReg">
|
||||
{{#if Template.subscriptionsReady}}
|
||||
{{#if $not currentUser}}
|
||||
<div id="registrationForm">
|
||||
<div class="container">
|
||||
{{#if $eq allowedReg true}}
|
||||
<h3>System Admin Registration</h3>
|
||||
<p>If you want to disable System Admin registration after creating this account, please check the box.</p>
|
||||
<div class="row">
|
||||
<div class="col s12">
|
||||
<div class="card">
|
||||
<div class="card-content">
|
||||
<form class="register">
|
||||
<div class="row">
|
||||
<div class="col s12 input-field">
|
||||
<input type="text" name="name" class="name {{#if $eq misName true}}red lighten-3{{/if}}" id="name" />
|
||||
<label for="name">Your Full Name *</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col s12 input-field">
|
||||
<input type="email" name="email" id="email" class="email {{#if $eq misEmail true}}red lighten-3{{/if}}" />
|
||||
<label for="email">Email *</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col s12 input-field">
|
||||
<input type="password" name="password" id="password" class="password {{#if $eq misPass true}}red lighten-3{{/if}}" />
|
||||
<label for="password">Password *</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col s12 input-field {{#if $eq canReg false}}orange lighten-1{{/if}}">
|
||||
<input type="password" name="passwordConfirm" id="passwordConfirm" class="passwordConfirm" />
|
||||
<label for="passwordConfirm">Confirm Password *</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col s12">
|
||||
<p>
|
||||
<label>
|
||||
<input type="checkbox" id="disableSysAdminReg" />
|
||||
<span>Disable Future System Admin Registrations</span>
|
||||
</label>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col s12">
|
||||
<a id="registerMe" class="waves-effect waves-light btn registerMe {{#if $eq canReg false}}grey{{else}}green darken-1{{/if}}">Register</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="card-action">
|
||||
<a href="#" id="sysAdminLogin">Sign In</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{else}}
|
||||
<h3>System Admin Registration Disabled</h3>
|
||||
<p>A system administrator has disabled the ability to register as a new system admin. If you believe this was done mistakenly, contact a current system administrator for this system, and have them change this setting.</p>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
</template>
|
||||
|
|
@ -1,118 +0,0 @@
|
|||
import { SysConfig } from '../../../imports/api/systemConfig.js';
|
||||
|
||||
Template.systemAdminReg.onCreated(function() {
|
||||
this.subscribe("SystemConfig");
|
||||
});
|
||||
|
||||
Template.systemAdminReg.onRendered(function() {
|
||||
Session.set("canReg", false);
|
||||
Session.set("misName", false);
|
||||
Session.set("misEmail", false);
|
||||
Session.set("misPass", false);
|
||||
});
|
||||
|
||||
Template.systemAdminReg.helpers({
|
||||
allowedReg: function() {
|
||||
let sysconf = SysConfig.findOne();
|
||||
if (typeof sysconf == 'undefined') {
|
||||
return true;
|
||||
} else {
|
||||
console.dir(sysconf);
|
||||
return sysconf.canReg;
|
||||
}
|
||||
},
|
||||
canReg: function() {
|
||||
return Session.get("canReg");
|
||||
},
|
||||
misName: function() {
|
||||
return Session.get("misName");
|
||||
},
|
||||
misEmail: function() {
|
||||
return Session.get("misEmail");
|
||||
},
|
||||
misPass: function() {
|
||||
return Session.get("misPass");
|
||||
},
|
||||
});
|
||||
|
||||
Template.systemAdminReg.events({
|
||||
'click #registerMe' (event) {
|
||||
event.preventDefault();
|
||||
if (Session.get("canReg") == false) {
|
||||
// console.log("reg disabled.");
|
||||
} else {
|
||||
let name = $("#name").val();
|
||||
let email = $("#email").val();
|
||||
let pass = $("#password").val();
|
||||
let disableSysAdReg = $("#disableSysAdminReg").prop("checked");
|
||||
|
||||
|
||||
if (name == "" || name == null) {
|
||||
Session.set("misName", true);
|
||||
}
|
||||
|
||||
if (email == "" || email == null) {
|
||||
Session.set("misEmail", true);
|
||||
}
|
||||
|
||||
if (pass == "" || pass == null) {
|
||||
Session.set("misPass", true);
|
||||
}
|
||||
|
||||
if (name == "" || name == null || email == "" || email == null || pass == "" || pass == null) {
|
||||
console.log("required info missing.");
|
||||
} else {
|
||||
// call meteor method to create user and add them to sys admin role.
|
||||
Accounts.createUser({
|
||||
email: email,
|
||||
password: pass,
|
||||
profile: {
|
||||
fullname: name,
|
||||
}
|
||||
});
|
||||
|
||||
let userId = Meteor.userId();
|
||||
console.log("User ID: " + userId);
|
||||
Meteor.call("addToRole", "systemadmin", function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR: ROLES - Error adding user to role: " + err);
|
||||
} else {
|
||||
Meteor.call('add.noSysAdminReg', function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR: SYS ADMIN REG - Error setting system admin registration as disabled: " + err);
|
||||
} else {
|
||||
FlowRouter.go('/dashboard');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
'keyup #passwordConfirm' (event) {
|
||||
let pwd = $("#password").val();
|
||||
let pwdconf = $("#passwordConfirm").val();
|
||||
|
||||
if (pwd == pwdconf) {
|
||||
// console.log("passwords match");
|
||||
Session.set("canReg", true);
|
||||
} else {
|
||||
// console.log("passwords don't match");
|
||||
Session.set("canReg", false);
|
||||
}
|
||||
},
|
||||
'change #email' (event) {
|
||||
let email = $("#email").val();
|
||||
var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
|
||||
let isEmail = regex.test(email);
|
||||
if (isEmail == false) {
|
||||
Session.set("misEmail", true);
|
||||
} else {
|
||||
Session.set("misEmail", false);
|
||||
}
|
||||
},
|
||||
'click #sysAdminLogin' (event) {
|
||||
event.preventDefault();
|
||||
FlowRouter.go('/sysAdminlogin');
|
||||
},
|
||||
});
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
Template.teacherLogin.onCreated(function() {
|
||||
|
||||
});
|
||||
|
||||
Template.teacherLogin.onRendered(function() {
|
||||
|
||||
});
|
||||
|
||||
Template.teacherLogin.helpers({
|
||||
areFilled: function() {
|
||||
return Session.get("filledFields");
|
||||
},
|
||||
});
|
||||
|
||||
Template.teacherLogin.events({
|
||||
'click #logmein' (event) {
|
||||
event.preventDefault();
|
||||
console.log("clicked login");
|
||||
let email = $("#email").val();
|
||||
let pass = $("#password").val();
|
||||
|
||||
if (email == null || email == "" || pass == "" || pass == null) {
|
||||
Session.set("filledFields", false);
|
||||
return;
|
||||
} else {
|
||||
Meteor.loginWithPassword(email, pass);
|
||||
}
|
||||
},
|
||||
'click #teacherReg' (event) {
|
||||
event.preventDefault();
|
||||
FlowRouter.go('/teachReg');
|
||||
},
|
||||
});
|
||||
|
|
@ -2,14 +2,32 @@
|
|||
{{#if isInRole 'systemadmin'}}
|
||||
<h3>User Management</h3>
|
||||
<div class="row">
|
||||
<div class="col s12 m6 l4 input-field" id="usersListCol">
|
||||
|
||||
</div>
|
||||
<div class="col s12 m6 l4 input-field" id="userAssignedRoleCol">
|
||||
|
||||
</div>
|
||||
<div class="col s12 m6 l4" id="assignRoleBtnCol">
|
||||
|
||||
<div class="col s12 m12 l12">
|
||||
<table class="striped highlight responsive-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Email</th>
|
||||
<th>Role</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each userInfo}}
|
||||
<tr>
|
||||
<td>{{userName}}</td>
|
||||
<td>{{userEmail}}</td>
|
||||
<td>{{userRole}}</td>
|
||||
<td>
|
||||
<div class="input-field">
|
||||
<i class="material-icons clickable deleteUser">delete</i>
|
||||
<i class="material-icons clickable editUser">edit</i>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
|
|
|||
|
|
@ -5,13 +5,37 @@ Template.userMgmt.onCreated(function() {
|
|||
});
|
||||
|
||||
Template.userMgmt.onRendered(function() {
|
||||
|
||||
$('select').formSelect();
|
||||
});
|
||||
|
||||
Template.userMgmt.helpers({
|
||||
|
||||
userInfo: function() {
|
||||
return Meteor.users.find({});
|
||||
},
|
||||
userName: function() {
|
||||
return this.profile.fullname;
|
||||
},
|
||||
userEmail: function() {
|
||||
return this.emails[0].address;
|
||||
},
|
||||
userRole: function() {
|
||||
return Roles.getRolesForUser( this._id );
|
||||
}
|
||||
});
|
||||
|
||||
Template.userMgmt.events({
|
||||
"click .editUser" (event) {
|
||||
event.preventDefault();
|
||||
|
||||
let userId = this._id;
|
||||
// take action
|
||||
console.log("Edit called on: " + userId);
|
||||
},
|
||||
"click .deleteUser" (event) {
|
||||
event.preventDefault();
|
||||
|
||||
let userId = this._id;
|
||||
// take action
|
||||
console.log("Delete called on : " + userId);
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue