LT-196: Add verifyEmail property under public property in settings.json to control emailVerification template

- Add mailServerSettings in settings.json
This commit is contained in:
Aysel Afsar 2016-02-28 15:25:23 -05:00
parent 813c68881a
commit c5651e7e04
5 changed files with 55 additions and 43 deletions

View File

@ -1,9 +1,7 @@
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);
// verifyEmail controls whether emailVerification template will be rendered or not
var verifyEmail = Meteor.settings && Meteor.settings.public && Meteor.settings.public.verifyEmail || false;
// Re-add any tab data saved in the Session
Object.keys(ViewerData).forEach(function(contentId) {
@ -34,12 +32,10 @@ var routerOptions = {
data: data
};
Router.route('/', function() {
// Check user is logged in
if(Meteor.user() && Meteor.userId()) {
if (!Meteor.user().emails[0].verified && Session.get("verifyEmail")) {
if (!Meteor.user().emails[0].verified && verifyEmail) {
this.render('emailVerification', routerOptions);
} else {
this.render('worklist', routerOptions);
@ -53,7 +49,7 @@ Router.route('/', function() {
Router.route('/worklist', function() {
// Check user is logged in
if(Meteor.user() && Meteor.userId()) {
if (!Meteor.user().emails[0].verified && Session.get("verifyEmail")) {
if (!Meteor.user().emails[0].verified && verifyEmail) {
this.render('emailVerification', routerOptions);
} else {
this.render('worklist', routerOptions);

View File

@ -29,7 +29,10 @@ Meteor.startup(function() {
aeTitle: 'ORTHANC',
default: true
}],
defaultServiceType: 'dicomWeb'
"defaultServiceType": 'dicomWeb',
"public": {
"verifyEmail": false
}
//defaultServiceType: 'dimse'
};

View File

@ -1,34 +1,34 @@
Meteor.startup(function () {
/*Meteor.startup(function () {
// Mail server settings
var username = Meteor.settings && Meteor.settings.mailServerSettings && Meteor.settings.mailServerSettings.username || null;
var password = Meteor.settings && Meteor.settings.mailServerSettings && Meteor.settings.mailServerSettings.password || null;
var server = Meteor.settings && Meteor.settings.mailServerSettings && Meteor.settings.mailServerSettings.server || null;
var port = Meteor.settings && Meteor.settings.mailServerSettings && Meteor.settings.mailServerSettings.port || null;
var verifyEmail = Meteor.settings && Meteor.settings.public && Meteor.settings.public.verifyEmail || false;
// Mail server settings
var username = "";
var password = "";
var server = "";
var port = "";
if (verifyEmail && username && password && server && port) {
Accounts.emailTemplates.siteName = 'Lesion Tracker';
Accounts.emailTemplates.from = 'Lesion Tracker Admin <'+username+'>';
Accounts.emailTemplates.siteName = 'Lesion Tracker';
Accounts.emailTemplates.from = 'Lesion Tracker Admin <'+username+'>';
process.env.MAIL_URL = 'smtp://' +
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';
};
// 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;
};
// 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
});
});
*/
// Send email when account is created
Accounts.config({
sendVerificationEmail: true
});
}
});

View File

@ -24,15 +24,20 @@ Template.lesionTrackerLayout.helpers({
},
currentUser: function() {
if (Meteor.user() && Meteor.userId()) {
if (Session.get("verifyEmail")) {
if (Meteor.user().emails[0].verified) {
return true;
}
return false;
}
var verifyEmail = Meteor.settings && Meteor.settings.public && Meteor.settings.public.verifyEmail || false;
if (!Meteor.user() || !Meteor.userId()) {
return false;
}
if (!verifyEmail) {
return true;
}
if (Meteor.user().emails[0].verified) {
return true;
}
return false;
}
});
@ -44,7 +49,7 @@ Template.lesionTrackerLayout.onCreated(function() {
// Show countdown dialog
var handle;
$(document).on('TriggerOpenTimeoutCountdownDialog', function(e, leftTime) {
// TODO: Show modal dialog
// Show modal dialog
handle = setInterval(function() {
leftTime--;
// Set countdownDialogLeftTime session

View File

@ -23,6 +23,14 @@
"staleSessionPurgeInterval": 15000,
"staleSessionActivityEvents": "mousemove click keydown",
"showCountdownDialog": true,
"dialogTimeout": 30000
"dialogTimeout": 30000,
"verifyEmail": false
},
"mailServerSettings": {
"username": "",
"password": "",
"server": "",
"port": ""
}
}