From 74d97ee2c3430af8fba8da28fc15da837a44ffc6 Mon Sep 17 00:00:00 2001 From: Keith Irwin Date: Tue, 11 Apr 2017 21:37:14 -0400 Subject: [PATCH] Added emails, changes to CSS, more login logic --- config/mail.js | 54 +++++++++++++++++++++++++++--------------- config/middleware.js | 3 +-- config/routes/admin.js | 21 ++++++++++++++-- static/css/base.css | 8 +++---- views/privacy.html | 4 ++-- views/settings.html | 11 ++++----- 6 files changed, 65 insertions(+), 36 deletions(-) diff --git a/config/mail.js b/config/mail.js index 9fec741..66b4d57 100644 --- a/config/mail.js +++ b/config/mail.js @@ -1,6 +1,7 @@ 'use strict'; -const nodemailer = require('nodemailer'); +const nodemailer = require('nodemailer'), + env = require('./env.js'); let transporter = nodemailer.createTransport({ host: 'keithirwin.us', @@ -11,30 +12,45 @@ let transporter = nodemailer.createTransport({ user: 'NoReply@tracman.org', pass: 'Ei0UwfrZuE' }, - logger: true, - debug: true + // logger: true, + // debug: true }); /* Confirm login */ // transporter.verify(function(err, success) { // if (err){ console.error(`SMTP Error: ${err}`); } -// if (success){ -// console.log("SMTP ready..."); -// } else { -// console.error("SMTP not ready!"); -// } +// console.log(`SMTP ${!success?'not ':''}ready...`); // }); /* Send test email */ -transporter.sendMail({ - to: `"Keith Irwin" `, - from: '"Tracman" ', - subject: 'Test email', - text: "Looks like everything's working", -}).then(function(){ - console.log("Email should have sent..."); -}).catch(function(err){ - console.error(err); -}); +// transporter.sendMail({ +// to: `"Keith Irwin" `, +// from: '"Tracman" ', +// subject: 'Test email', +// text: "Looks like everything's working", +// html: "" +// }).then(function(){ +// console.log("Email should have sent..."); +// }).catch(function(err){ +// console.error(err); +// }); -module.exports = transporter.sendMail.bind(transporter); \ No newline at end of file +module.exports = { + + send: transporter.sendMail.bind(transporter), + + text: function(text) { + return `Tracman\n\n${text}\n\nDo not reply to this email\nFor information about why you received this email, see the privacy policy at ${env.url}/privacyy#email`; + }, + + html: function(text) { + return `

+Tracman

${text}

Do not reply to this email. For information about why you recieved this email, see our privacy policy.

`; + }, + + from: `"Tracman" `, + + to: function(user) { + return `"${user.name}" <${user.email}>`; + } + +}; \ No newline at end of file diff --git a/config/middleware.js b/config/middleware.js index eda3794..e465963 100644 --- a/config/middleware.js +++ b/config/middleware.js @@ -6,8 +6,7 @@ module.exports = { // Throw error throwErr: function(req,err){ - console.error('middleware.js:5 '+typeof err); - console.error('Middleware error:'+err+'\nfor request:\n'+req); + console.error('Middleware error:'+err.message+'\nfor request:\n'+req); if (env.mode==='production') { req.flash('danger', 'An error occured.
Would you like to report it?'); } else { // development diff --git a/config/routes/admin.js b/config/routes/admin.js index 08b4bac..851a078 100644 --- a/config/routes/admin.js +++ b/config/routes/admin.js @@ -2,7 +2,8 @@ const router = require('express').Router(), mw = require('../middleware.js'), - User = require('../models.js').user; + User = require('../models.js').user, + mail = require('../mail.js'); router.route('/') .all(mw.ensureAdmin, function(req,res,next){ @@ -47,7 +48,23 @@ router.route('/users') else { req.flash('success', ''+user.name+' deleted.'); } res.redirect('/admin#users'); }); - } else { console.log('ERROR! POST without action sent. '); next(); } + } else { console.error('ERROR! POST without action sent. '); next(); } }); + +router.route('/testmail').get(function(req,res,next){ + mail.send({ + to: `"Keith Irwin" `, + from: mail.from, + subject: 'Test email', + text: mail.text("Looks like everything's working! "), + html: mail.html("

Looks like everything's working!

") + }).then(function(){ + console.log("Test email should have sent..."); + res.sendStatus(200); + }).catch(function(err){ + mw.throwErr(err); + next(); + }); +}); module.exports = router; \ No newline at end of file diff --git a/static/css/base.css b/static/css/base.css index de4333a..d276740 100644 --- a/static/css/base.css +++ b/static/css/base.css @@ -36,7 +36,7 @@ h1, h2, h3 { position: relative; z-index: 6; } -h1,h2,h3,h4 { font-weight: 600; } +h1, h2, h3, h4 { font-weight: 600; } h1 { font-size: 48px; line-height: 46px; } @@ -58,12 +58,10 @@ main a:hover:not(.btn) { color: #fbc93d; text-decoration: underline; } -.light a:not(.btn) { - color:#111; +a.underline { text-decoration: underline; } -.light a:hover { - color:#111; +a.underline:hover:not(.btn) { text-decoration: none; } diff --git a/views/privacy.html b/views/privacy.html index a8b9e8b..873ed4e 100644 --- a/views/privacy.html +++ b/views/privacy.html @@ -8,13 +8,13 @@

In lieu of legalease, which I don't speak, here is a quick rundown of what Tracman does with your data (such as location).

-

Location history

+

Location history

Your location is saved on the database as long as you have it "set" or "tracking". If you "clear" the data, it will be deleted from the database too. This doesn't mean all copies are destroyed. Our servers keep occasional backups, and caches could exist on other servers (google index, wayback archive, etc).

This means that all public access to your location is essentially deleted when you clear it. But anyone could record your location while it's publicly available and rebroadcast it. Tracman doesn't store location histories (except as mentioned above), but histories may exist elsewhere! If you have (or plan to have) trouble with the law, don't use Tracman. Authorities have easy access to those histories.

-

Email addresses

+

Email addresses

Tracman stores email addresses so we can contact users for important stuff (urgent security updates, deletion requests, lost passwords). We will never subscribe you to anything else by default.

diff --git a/views/settings.html b/views/settings.html index 2e982e1..a8ab0da 100644 --- a/views/settings.html +++ b/views/settings.html @@ -17,9 +17,9 @@

Account settings

- - -
+ + +
@@ -35,7 +35,6 @@ #social-connect > .btn { display: flex; align-items: center; - text-align: center; margin-left: 1vw; margin-right: 1vw; flex-grow: 1; @@ -98,8 +97,8 @@

Map settings