LT-196: Verify user's email on signup

This commit is contained in:
Aysel Afsar 2016-02-28 12:58:05 -05:00
parent ee8fb5492c
commit 813c68881a
11 changed files with 110 additions and 14 deletions

View File

@ -52,3 +52,4 @@ aldeed:template-extension@4.0.0
zuuk:stale-session
gilbertwat:bootstrap3-daterangepicker
silentcicero:jszip
email

View File

@ -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';
});
}
*/

View File

@ -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>

View File

@ -0,0 +1,5 @@
Template.emailVerification.helpers({
emailAddress: function() {
return Meteor.user().emails[0].address;
}
});

View File

@ -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

View File

@ -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);
});
}
}
});
});

View File

@ -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);
}
});

View 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
});
});
*/

View File

@ -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

View File

@ -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;
}
});

View File

@ -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()]
}
});
});