diff --git a/infrastructure/web/routes/login.js b/infrastructure/web/routes/login.js index 604bf96..3aa644a 100644 --- a/infrastructure/web/routes/login.js +++ b/infrastructure/web/routes/login.js @@ -1,6 +1,6 @@ const express = require('express') const router = new express.Router() -const {check, validationResult} = require('express-validator') +const { check, validationResult } = require('express-validator') const randomWord = require('random-word') const config = require('../../../application/config') @@ -10,49 +10,49 @@ const helper = new(Helper) const purgeTime = helper.purgeTimeElemetBuilder() router.get('/', (req, res, _next) => { - res.render('login', { - title: `${config.http.branding[0]} | Your temporary Inbox`, - username: randomWord(), - purgeTime: purgeTime, - domains: helper.getDomains(), - branding: config.http.branding, - }) + res.render('login', { + title: `${config.http.branding[0]} | Your temporary Inbox`, + username: randomWord(), + purgeTime: purgeTime, + domains: helper.getDomains(), + branding: config.http.branding, + example: config.email.examples.account, + }) }) router.get('/inbox/random', (req, res, _next) => { - res.redirect(`/inbox/${randomWord()}@${config.email.domains[Math.floor(Math.random() * config.email.domains.length)]}`) + res.redirect(`/inbox/${randomWord()}@${config.email.domains[Math.floor(Math.random() * config.email.domains.length)]}`) }) router.get('/logout', (req, res, _next) => { - /** - * If we ever need a logout sequence, now we can have one! - */ + /** + * If we ever need a logout sequence, now we can have one! + */ - res.redirect('/') + res.redirect('/') }) router.post( - '/', - [ - check('username').isLength({min: 1}), - check('domain').isIn(config.email.domains) - ], - (req, res) => { - const errors = validationResult(req) - if (!errors.isEmpty()) { - return res.render('login', { - userInputError: true, - title: `${config.http.branding[0]} | Your temporary Inbox`, - purgeTime: purgeTime, - username: randomWord(), - domains: helper.getDomains(), - branding: config.http.branding, - }) - } + '/', [ + check('username').isLength({ min: 1 }), + check('domain').isIn(config.email.domains) + ], + (req, res) => { + const errors = validationResult(req) + if (!errors.isEmpty()) { + return res.render('login', { + userInputError: true, + title: `${config.http.branding[0]} | Your temporary Inbox`, + purgeTime: purgeTime, + username: randomWord(), + domains: helper.getDomains(), + branding: config.http.branding, + }) + } - res.redirect(`/inbox/${req.body.username}@${req.body.domain}`) - } + res.redirect(`/inbox/${req.body.username}@${req.body.domain}`) + } ) -module.exports = router +module.exports = router \ No newline at end of file diff --git a/infrastructure/web/views/login.twig b/infrastructure/web/views/login.twig index c78b2df..ec3554b 100644 --- a/infrastructure/web/views/login.twig +++ b/infrastructure/web/views/login.twig @@ -3,7 +3,7 @@ {% block body %}