From 6327535653f5ff1abc9f5bbf666268d41abb4d74 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Wed, 5 Feb 2020 20:21:42 +0200 Subject: Implement email console backend --- backend/src/authn.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/backend/src/authn.js b/backend/src/authn.js index 8c12396..1980aed 100644 --- a/backend/src/authn.js +++ b/backend/src/authn.js @@ -1,8 +1,9 @@ const base64 = require('base-64'); const sha512 = require('js-sha512'); const shortid = require('shortid'); -const db = require('./db'); const owaspPw = require('owasp-password-strength-test'); +const db = require('./db'); +const { consoleBackend } = require('./email'); const buildSessionCookie = ({ username, sessionToken, isLogout }) => { if (!isLogout) { @@ -113,6 +114,12 @@ const registerRoute = async (req, res) => { await db('tokens').insert({ user_id: user.id, type: 'session', value: sessionTokenHash }); res.set('Set-Cookie', buildSessionCookie({ username, sessionToken, remember: false, isLogout: false })); + + await consoleBackend.send({ + recipients: [ username ], + subject: `Welcome to the service, ${username}!`, + body: `Welcome.\n\nLog in at http://localhost:3000.\n\nBR,\nTeam`, + }); return res.json({ username, }); -- cgit v1.3