Re-design routes

pull/1/head
ClaraCrazy 2023-11-03 06:11:17 +01:00
parent df027310a8
commit 0c89b3c810
7 changed files with 24 additions and 13 deletions

View File

@ -60,7 +60,7 @@ router.get(
try { try {
const mailProcessingService = req.app.get('mailProcessingService') const mailProcessingService = req.app.get('mailProcessingService')
await mailProcessingService.deleteSpecificEmail(req.params.address, req.params.uid) await mailProcessingService.deleteSpecificEmail(req.params.address, req.params.uid)
res.redirect(`/${req.params.address}`) res.redirect(`/inbox/${req.params.address}`)
} catch (error) { } catch (error) {
console.error('error while deleting email', error) console.error('error while deleting email', error)
next(error) next(error)

View File

@ -15,8 +15,17 @@ router.get('/', (req, res, _next) => {
}) })
}) })
router.get('/random', (req, res, _next) => { router.get('/inbox/random', (req, res, _next) => {
res.redirect(`/${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!
*/
res.redirect('/')
}) })
router.post( 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}`)
} }
) )

View File

@ -1,7 +1,7 @@
{% extends 'layout.twig' %} {% extends 'layout.twig' %}
{% block body %} {% block body %}
<div style="float: right"><a href="/login"> Logout</a></div> <div style="float: right"><a href="/logout"> Logout</a></div>
<h1>{{message}}</h1> <h1>{{message}}</h1>
<h2>{{error.status}}</h2> <h2>{{error.status}}</h2>

View File

@ -7,7 +7,7 @@
}); });
</script> </script>
<div style="float: right"><a href="/login"> Logout</a></div> <div style="float: right"><a href="/logout"> Logout</a></div>
<h1>{{ address }}</h1> <h1>{{ address }}</h1>
{% for mail in mailSummaries %} {% for mail in mailSummaries %}
<a href="{{ mail.to[0] }}/{{ mail.uid }}" class="no-link-color"> <a href="{{ mail.to[0] }}/{{ mail.uid }}" class="no-link-color">

View File

@ -13,7 +13,7 @@
Your input was invalid. Please try other values. Your input was invalid. Please try other values.
</blockquote> </blockquote>
{% endif %} {% endif %}
<form method="POST" action="/login"> <form method="POST" action="/">
<fieldset> <fieldset>
<label for="nameField">Name</label> <label for="nameField">Name</label>
<input type="text" id="nameField" name="username" value="{{ username }}"> <input type="text" id="nameField" name="username" value="{{ username }}">
@ -27,7 +27,7 @@
</div> </div>
<div class="buttons"> <div class="buttons">
<input class="button" type="submit" value="Access This Inbox"> <input class="button" type="submit" value="Access This Inbox">
<a class="button" href="/login/random">Create Random Inbox</a> <a class="button" href="/inbox/random">Create Random Inbox</a>
</div> </div>
</fieldset> </fieldset>
</form> </form>

View File

@ -3,13 +3,13 @@
{% block body %} {% block body %}
<div style="float: right; text-align: end;"> <div style="float: right; text-align: end;">
<a href="/{{ address }}"> <a href="/inbox/{{ address }}">
← Return to inbox</a> ← Return to inbox</a>
<br> <br>
<a href="/{{ address }}/delete/{{ uid }}"> <a href="/inbox/{{ address }}/delete/{{ uid }}">
Delete Email</a> Delete Email</a>
<br> <br>
<a href="/login"> <a href="/logout">
Logout</a> Logout</a>
</div> </div>
<hr> <hr>

View File

@ -41,12 +41,14 @@ app.use(
) )
Twig.extendFilter('sanitizeHtml', sanitizeHtmlTwigFilter) Twig.extendFilter('sanitizeHtml', sanitizeHtmlTwigFilter)
/**
app.get('/', (req, res, _next) => { app.get('/', (req, res, _next) => {
res.redirect('/login') res.redirect('/login')
}) })
**/
app.use('/login', loginRouter) app.use('/', loginRouter)
app.use('/', inboxRouter) app.use('/inbox', inboxRouter)
// Catch 404 and forward to error handler // Catch 404 and forward to error handler
app.use((req, res, next) => { app.use((req, res, next) => {