diff options
| author | Jan Tuomi <jan.tuomi@eficode.com> | 2020-02-05 20:21:42 +0200 |
|---|---|---|
| committer | Jan Tuomi <jan.tuomi@eficode.com> | 2020-02-05 20:21:42 +0200 |
| commit | 6327535653f5ff1abc9f5bbf666268d41abb4d74 (patch) | |
| tree | a5d99f599bea56cc54cfac1ecda01db083f7781c | |
| parent | dacd67f2dae7db7e8717f3c67c89101926922fd1 (diff) | |
Implement email console backend
| -rw-r--r-- | backend/src/authn.js | 9 |
1 files changed, 8 insertions, 1 deletions
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, }); |
