LT-196: Verify user's email on signup
This commit is contained in:
parent
ee8fb5492c
commit
813c68881a
@ -52,3 +52,4 @@ aldeed:template-extension@4.0.0
|
||||
zuuk:stale-session
|
||||
gilbertwat:bootstrap3-daterangepicker
|
||||
silentcicero:jszip
|
||||
email
|
||||
|
||||
@ -25,6 +25,7 @@ if (Meteor.isClient){
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
if (Meteor.isServer){
|
||||
Accounts.emailTemplates.siteName = 'AwesomeSite';
|
||||
Accounts.emailTemplates.from = 'AwesomeSite Admin <accounts@example.com>';
|
||||
@ -42,3 +43,4 @@ if (Meteor.isServer){
|
||||
//process.env.MAIL_URL = 'smtp://sandboxid.mailgun.org:mypassword@smtp.mailgun.org:587';
|
||||
});
|
||||
}
|
||||
*/
|
||||
|
||||
@ -0,0 +1,8 @@
|
||||
<template name="emailVerification">
|
||||
<div id="emailVerification">
|
||||
<div id="emailVerificationContent">
|
||||
<h3>Verify Your Email Address</h3>
|
||||
<p>We need to verify your email address. We've sent an email to <b>{{emailAddress}}</b> to verify your address. Please click the link in your email to continue.</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@ -0,0 +1,5 @@
|
||||
Template.emailVerification.helpers({
|
||||
emailAddress: function() {
|
||||
return Meteor.user().emails[0].address;
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,15 @@
|
||||
#emailVerification
|
||||
#emailVerificationContent
|
||||
position: absolute
|
||||
top: 0
|
||||
bottom: 0
|
||||
left: 0
|
||||
right: 0
|
||||
margin: auto
|
||||
width: 60%
|
||||
height: 20%
|
||||
z-index: 100
|
||||
border-radius: 5px
|
||||
padding: 10px 20px 10px 20px
|
||||
background-color: rgba(255,255,255,1)
|
||||
outline: none
|
||||
@ -263,10 +263,13 @@ Template.viewer.onCreated(function() {
|
||||
});
|
||||
|
||||
// Set active tool for timepoint
|
||||
dataContext.timepointIds.forEach(function(timepointId) {
|
||||
var timepoint = Timepoints.findOne({timepointId: timepointId});
|
||||
setTimepointActiveTool(timepoint);
|
||||
});
|
||||
if (dataContext && dataContext.timepointIds) {
|
||||
dataContext.timepointIds.forEach(function(timepointId) {
|
||||
var timepoint = Timepoints.findOne({timepointId: timepointId});
|
||||
setTimepointActiveTool(timepoint);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,5 +1,10 @@
|
||||
Session.setDefault('ViewerData', {});
|
||||
|
||||
// TODO: verifyEmail variable will be removed when mail server is set.
|
||||
// verifyEmail controls email verification template
|
||||
// set verifyEmail as false if email server settings are not ready
|
||||
Session.setDefault('verifyEmail', false);
|
||||
|
||||
// Re-add any tab data saved in the Session
|
||||
Object.keys(ViewerData).forEach(function(contentId) {
|
||||
var tabData = ViewerData[contentId];
|
||||
@ -29,21 +34,33 @@ var routerOptions = {
|
||||
data: data
|
||||
};
|
||||
|
||||
|
||||
|
||||
Router.route('/', function() {
|
||||
// Check user is logged in
|
||||
if (!Meteor.user() || !Meteor.userId()) {
|
||||
this.render('entrySignIn', routerOptions);
|
||||
if(Meteor.user() && Meteor.userId()) {
|
||||
if (!Meteor.user().emails[0].verified && Session.get("verifyEmail")) {
|
||||
this.render('emailVerification', routerOptions);
|
||||
} else {
|
||||
this.render('worklist', routerOptions);
|
||||
}
|
||||
|
||||
} else {
|
||||
this.render('worklist', routerOptions);
|
||||
this.render('entrySignIn', routerOptions);
|
||||
}
|
||||
});
|
||||
|
||||
Router.route('/worklist', function() {
|
||||
// Check user is logged in
|
||||
if (!Meteor.user() || !Meteor.userId()) {
|
||||
this.render('entrySignIn', routerOptions);
|
||||
if(Meteor.user() && Meteor.userId()) {
|
||||
if (!Meteor.user().emails[0].verified && Session.get("verifyEmail")) {
|
||||
this.render('emailVerification', routerOptions);
|
||||
} else {
|
||||
this.render('worklist', routerOptions);
|
||||
}
|
||||
|
||||
} else {
|
||||
this.render('worklist', routerOptions);
|
||||
this.render('entrySignIn', routerOptions);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
34
LesionTracker/server/email.js
Normal file
34
LesionTracker/server/email.js
Normal file
@ -0,0 +1,34 @@
|
||||
|
||||
/*Meteor.startup(function () {
|
||||
|
||||
// Mail server settings
|
||||
var username = "";
|
||||
var password = "";
|
||||
var server = "";
|
||||
var port = "";
|
||||
|
||||
Accounts.emailTemplates.siteName = 'Lesion Tracker';
|
||||
Accounts.emailTemplates.from = 'Lesion Tracker Admin <'+username+'>';
|
||||
|
||||
|
||||
process.env.MAIL_URL = 'smtp://' +
|
||||
encodeURIComponent(username) + ':' +
|
||||
encodeURIComponent(password) + '@' +
|
||||
encodeURIComponent(server) + ':' + port;
|
||||
|
||||
// Subject line of the email.
|
||||
Accounts.emailTemplates.verifyEmail.subject = function(user) {
|
||||
return 'Confirm Your Email Address for Lesion Tracker';
|
||||
};
|
||||
|
||||
// Email text
|
||||
Accounts.emailTemplates.verifyEmail.text = function(user, url) {
|
||||
return 'Thank you for registering. Please click on the following link to verify your email address: \r\n' + url;
|
||||
};
|
||||
|
||||
// Send email when account is created
|
||||
Accounts.config({
|
||||
sendVerificationEmail: true
|
||||
});
|
||||
});
|
||||
*/
|
||||
@ -10,5 +10,5 @@
|
||||
width: 50px
|
||||
|
||||
// TODO: Fix theming in active-entry so we don't have to do this
|
||||
.entryPage .wrapper-auth
|
||||
.entryPage .wrapper-auth,.subtitle-auth
|
||||
color: white !important
|
||||
@ -21,6 +21,19 @@ Template.lesionTrackerLayout.helpers({
|
||||
|
||||
showWorklistMenu: function() {
|
||||
return Template.instance().showWorklistMenu.get();
|
||||
},
|
||||
|
||||
currentUser: function() {
|
||||
if (Meteor.user() && Meteor.userId()) {
|
||||
if (Session.get("verifyEmail")) {
|
||||
if (Meteor.user().emails[0].verified) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -155,8 +155,6 @@ function search() {
|
||||
Session.set("searchResults", searchResults);
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@ -186,7 +184,7 @@ Template.worklistResult.onRendered(function() {
|
||||
ranges: {
|
||||
'Today': [moment(), moment()],
|
||||
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
|
||||
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
|
||||
'Last 30 Days': [moment().subtract(29, 'days'), moment()]
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user