mirror of
https://gitlab.com/bmcgonag/get_my.git
synced 2026-03-27 00:08:49 +00:00
initial commit
This commit is contained in:
parent
b7c7d8b449
commit
750811a81f
52 changed files with 25204 additions and 92 deletions
0
client/Accounts/ChildLogin/childLogin.html
Normal file
0
client/Accounts/ChildLogin/childLogin.html
Normal file
0
client/Accounts/ChildLogin/childLogin.js
Normal file
0
client/Accounts/ChildLogin/childLogin.js
Normal file
43
client/Accounts/ParentsLogin/parentLogin.html
Normal file
43
client/Accounts/ParentsLogin/parentLogin.html
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<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>
|
||||
33
client/Accounts/ParentsLogin/parentLogin.js
Normal file
33
client/Accounts/ParentsLogin/parentLogin.js
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
Template.parentLogin.onCreated(function() {
|
||||
|
||||
});
|
||||
|
||||
Template.parentLogin.onRendered(function() {
|
||||
|
||||
});
|
||||
|
||||
Template.parentLogin.helpers({
|
||||
areFilled: function() {
|
||||
return Session.get("filledFields");
|
||||
},
|
||||
});
|
||||
|
||||
Template.parentLogin.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 #parentReg' (event) {
|
||||
event.preventDefault();
|
||||
FlowRouter.go('/parentReg');
|
||||
},
|
||||
});
|
||||
123
client/Accounts/ParentsLogin/parentReg.js
Normal file
123
client/Accounts/ParentsLogin/parentReg.js
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
|
||||
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');
|
||||
},
|
||||
});
|
||||
56
client/Accounts/ParentsLogin/parentRegistration.html
Normal file
56
client/Accounts/ParentsLogin/parentRegistration.html
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
<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>
|
||||
50
client/Accounts/SystemAdmin/systemAdminLogin.html
Normal file
50
client/Accounts/SystemAdmin/systemAdminLogin.html
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<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>
|
||||
45
client/Accounts/SystemAdmin/systemAdminLogin.js
Normal file
45
client/Accounts/SystemAdmin/systemAdminLogin.js
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
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');
|
||||
},
|
||||
});
|
||||
69
client/Accounts/SystemAdmin/systemAdminReg.html
Normal file
69
client/Accounts/SystemAdmin/systemAdminReg.html
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
<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>
|
||||
118
client/Accounts/SystemAdmin/systemAdminReg.js
Normal file
118
client/Accounts/SystemAdmin/systemAdminReg.js
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
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');
|
||||
},
|
||||
});
|
||||
43
client/Accounts/TeacherLogin/teacherLogin.html
Normal file
43
client/Accounts/TeacherLogin/teacherLogin.html
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<template name="teacherLogin">
|
||||
{{#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>
|
||||
<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="teacherReg">Register</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
</template>
|
||||
33
client/Accounts/TeacherLogin/teacherLogin.js
Normal file
33
client/Accounts/TeacherLogin/teacherLogin.js
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
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');
|
||||
},
|
||||
});
|
||||
56
client/Accounts/TeacherLogin/teacherReg.html
Normal file
56
client/Accounts/TeacherLogin/teacherReg.html
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
<template name="teacherRegistration">
|
||||
{{#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>
|
||||
<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="teachLogin">Sign In</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
</template>
|
||||
127
client/Accounts/TeacherLogin/teacherReg.js
Normal file
127
client/Accounts/TeacherLogin/teacherReg.js
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
|
||||
Template.teacherRegistration.onCreated(function() {
|
||||
|
||||
});
|
||||
|
||||
Template.teacherRegistration.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.teacherRegistration.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.teacherRegistration.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", "teacher", function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR: ROLES - Error adding user to role: " + err);
|
||||
} else {
|
||||
// console.log("User should be added to role - teacher.");
|
||||
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 #teachLogin' (event) {
|
||||
event.preventDefault();
|
||||
FlowRouter.go('/teachlogin');
|
||||
},
|
||||
});
|
||||
16
client/Accounts/UserMgmt/userMgmt.html
Normal file
16
client/Accounts/UserMgmt/userMgmt.html
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<template name="userMgmt">
|
||||
{{#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>
|
||||
</div>
|
||||
{{/if}}
|
||||
</template>
|
||||
17
client/Accounts/UserMgmt/userMgmt.js
Normal file
17
client/Accounts/UserMgmt/userMgmt.js
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
|
||||
Template.userMgmt.onCreated(function() {
|
||||
|
||||
});
|
||||
|
||||
Template.userMgmt.onRendered(function() {
|
||||
|
||||
});
|
||||
|
||||
Template.userMgmt.helpers({
|
||||
|
||||
});
|
||||
|
||||
Template.userMgmt.events({
|
||||
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue