From 0c89b3c810c99e9cc812ef5849d4610749244bf8 Mon Sep 17 00:00:00 2001 From: ClaraCrazy Date: Fri, 3 Nov 2023 06:11:17 +0100 Subject: [PATCH] Re-design routes --- infrastructure/web/routes/inbox.js | 2 +- infrastructure/web/routes/login.js | 15 ++++++++++++--- infrastructure/web/views/error.twig | 2 +- infrastructure/web/views/inbox.twig | 2 +- infrastructure/web/views/login.twig | 4 ++-- infrastructure/web/views/mail.twig | 6 +++--- infrastructure/web/web.js | 6 ++++-- 7 files changed, 24 insertions(+), 13 deletions(-) diff --git a/infrastructure/web/routes/inbox.js b/infrastructure/web/routes/inbox.js index 43dbf83..7710227 100644 --- a/infrastructure/web/routes/inbox.js +++ b/infrastructure/web/routes/inbox.js @@ -60,7 +60,7 @@ router.get( try { const mailProcessingService = req.app.get('mailProcessingService') await mailProcessingService.deleteSpecificEmail(req.params.address, req.params.uid) - res.redirect(`/${req.params.address}`) + res.redirect(`/inbox/${req.params.address}`) } catch (error) { console.error('error while deleting email', error) next(error) diff --git a/infrastructure/web/routes/login.js b/infrastructure/web/routes/login.js index 0db83b8..656e53a 100644 --- a/infrastructure/web/routes/login.js +++ b/infrastructure/web/routes/login.js @@ -15,8 +15,17 @@ router.get('/', (req, res, _next) => { }) }) -router.get('/random', (req, res, _next) => { - res.redirect(`/${randomWord()}@${config.email.domains[Math.floor(Math.random() * config.email.domains.length)]}`) +router.get('/inbox/random', (req, res, _next) => { + 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! + */ + + res.redirect('/') }) router.post( @@ -38,7 +47,7 @@ router.post( }) } - res.redirect(`/${req.body.username}@${req.body.domain}`) + res.redirect(`/inbox/${req.body.username}@${req.body.domain}`) } ) diff --git a/infrastructure/web/views/error.twig b/infrastructure/web/views/error.twig index 095cef5..626a42d 100644 --- a/infrastructure/web/views/error.twig +++ b/infrastructure/web/views/error.twig @@ -1,7 +1,7 @@ {% extends 'layout.twig' %} {% block body %} -
Logout
+
Logout

{{message}}

{{error.status}}

diff --git a/infrastructure/web/views/inbox.twig b/infrastructure/web/views/inbox.twig index 126a53f..06b5489 100644 --- a/infrastructure/web/views/inbox.twig +++ b/infrastructure/web/views/inbox.twig @@ -7,7 +7,7 @@ }); -
Logout
+
Logout

{{ address }}

{% for mail in mailSummaries %} diff --git a/infrastructure/web/views/login.twig b/infrastructure/web/views/login.twig index 511ef78..d1d3c71 100644 --- a/infrastructure/web/views/login.twig +++ b/infrastructure/web/views/login.twig @@ -13,7 +13,7 @@ Your input was invalid. Please try other values. {% endif %} -
+
@@ -27,7 +27,7 @@
diff --git a/infrastructure/web/views/mail.twig b/infrastructure/web/views/mail.twig index 4ffef20..446fbe8 100644 --- a/infrastructure/web/views/mail.twig +++ b/infrastructure/web/views/mail.twig @@ -3,13 +3,13 @@ {% block body %}
- + ← Return to inbox
- + Delete Email
- + Logout

diff --git a/infrastructure/web/web.js b/infrastructure/web/web.js index 1448587..09531d4 100644 --- a/infrastructure/web/web.js +++ b/infrastructure/web/web.js @@ -41,12 +41,14 @@ app.use( ) Twig.extendFilter('sanitizeHtml', sanitizeHtmlTwigFilter) +/** app.get('/', (req, res, _next) => { res.redirect('/login') }) +**/ -app.use('/login', loginRouter) -app.use('/', inboxRouter) +app.use('/', loginRouter) +app.use('/inbox', inboxRouter) // Catch 404 and forward to error handler app.use((req, res, next) => {