diff --git a/locales/en.yml b/locales/en.yml index 6b2330f27..50845b96f 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -20,11 +20,13 @@ en: bio_offensive: "This bio is offensive" cancel: "Cancel" confirm_email: - click_to_confirm: "Click below to confirm your email address" + email_confirmation: "Email Confirmation" + click_to_confirm: "Click below to confirm your email address." confirm: "Confirm" password_reset: mail_sent: 'If you have a registered account, a password reset link was sent to that email' set_new_password: "Change Your Password" + change_password_help: "Please enter a new password to use to login. Make it secure!" new_password: "New Password" new_password_help: "Password must be at least 8 characters" confirm_new_password: "Confirm New Password" diff --git a/plugins/talk-plugin-profile-data/server/emails/download.html.ejs b/plugins/talk-plugin-profile-data/server/emails/download.html.ejs index c6aeb8e1e..00b6ad372 100644 --- a/plugins/talk-plugin-profile-data/server/emails/download.html.ejs +++ b/plugins/talk-plugin-profile-data/server/emails/download.html.ejs @@ -1 +1 @@ -

<%= t('email.download.download_link_ready') %> <%= t('email.download.download_archive') %>

+

<%= t('email.download.download_link_ready', organizationName, now.toLocaleString()) %> <%= t('email.download.download_archive') %>

diff --git a/plugins/talk-plugin-profile-data/server/emails/download.txt.ejs b/plugins/talk-plugin-profile-data/server/emails/download.txt.ejs index 4f719bc06..138ea1088 100644 --- a/plugins/talk-plugin-profile-data/server/emails/download.txt.ejs +++ b/plugins/talk-plugin-profile-data/server/emails/download.txt.ejs @@ -1,3 +1,3 @@ -<%= t('email.download.download_link_ready') %> +<%= t('email.download.download_link_ready', organizationName, now.toLocaleString()) %> <%= BASE_URL %>account/download#<%= token %> diff --git a/plugins/talk-plugin-profile-data/server/errors.js b/plugins/talk-plugin-profile-data/server/errors.js new file mode 100644 index 000000000..6261ebe89 --- /dev/null +++ b/plugins/talk-plugin-profile-data/server/errors.js @@ -0,0 +1,18 @@ +const { TalkError } = require('errors'); + +// ErrDownloadToken is returned in the event that the download is requested +// without a valid token. +class ErrDownloadToken extends TalkError { + constructor(err) { + super( + 'Token is invalid', + { + translation_key: 'DOWNLOAD_TOKEN_INVALID', + status: 400, + }, + { err } + ); + } +} + +module.exports = { ErrDownloadToken }; diff --git a/plugins/talk-plugin-profile-data/server/mutators.js b/plugins/talk-plugin-profile-data/server/mutators.js index e5d717978..5a897a2e1 100644 --- a/plugins/talk-plugin-profile-data/server/mutators.js +++ b/plugins/talk-plugin-profile-data/server/mutators.js @@ -4,6 +4,7 @@ const { DOWNLOAD_LINK_SUBJECT } = require('./constants'); async function sendDownloadLink({ user, + loaders: { Settings }, connectors: { errors, secrets, @@ -43,19 +44,25 @@ async function sendDownloadLink({ { jwtid: uuid.v4(), expiresIn: '1d', subject: DOWNLOAD_LINK_SUBJECT } ); + const now = new Date(); + + const { organizationName } = await Settings.load('organizationName'); + // Send the download link via the user's attached email account. await Users.sendEmail(user, { template: 'download', locals: { token, + organizationName, + now, }, - subject: I18n.t('email.download.subject'), + subject: I18n.t('email.download.subject', organizationName), }); // Amend the lastAccountDownload on the user. await User.update( { id: user.id }, - { $set: { 'metadata.lastAccountDownload': new Date() } } + { $set: { 'metadata.lastAccountDownload': now } } ); } diff --git a/plugins/talk-plugin-profile-data/server/router.js b/plugins/talk-plugin-profile-data/server/router.js index 5ef3b0cfc..00061c173 100644 --- a/plugins/talk-plugin-profile-data/server/router.js +++ b/plugins/talk-plugin-profile-data/server/router.js @@ -5,6 +5,7 @@ const { get, pick, kebabCase } = require('lodash'); const moment = require('moment'); const archiver = require('archiver'); const stringify = require('csv-stringify'); +const { ErrDownloadToken } = require('./errors'); async function verifyDownloadToken( { connectors: { services: { Users } } }, @@ -109,10 +110,7 @@ module.exports = router => { // Verify the token await verifyDownloadToken(req.context, token); } catch (err) { - // Log out the error, slurp it and send out the predefined error to the - // error handler. - console.error(err); - return next(new Error('invalid token')); + return next(new ErrDownloadToken(err)); } res.status(204).end(); diff --git a/plugins/talk-plugin-profile-data/server/views/download.ejs b/plugins/talk-plugin-profile-data/server/views/download.ejs index 53ee8a4e9..bc8e0aa54 100644 --- a/plugins/talk-plugin-profile-data/server/views/download.ejs +++ b/plugins/talk-plugin-profile-data/server/views/download.ejs @@ -1,19 +1,26 @@ - <%= t('download_landing.download_your_account') %> - - - <%- include(root + '/partials/head') %> + <%- include(root + '/partials/account') %> - +
-
-
- <%= t('download_landing.click_to_download') %> - -
+
+

<%= t('download_landing.download_your_account') %>

+

<%= t('download_landing.download_details') %>

+

<%= t('download_landing.all_information_included') %>

+ +
+
+ +
+