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 {
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)

View File

@ -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}`)
}
)

View File

@ -1,7 +1,7 @@
{% extends 'layout.twig' %}
{% 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>
<h2>{{error.status}}</h2>

View File

@ -7,7 +7,7 @@
});
</script>
<div style="float: right"><a href="/login"> Logout</a></div>
<div style="float: right"><a href="/logout"> Logout</a></div>
<h1>{{ address }}</h1>
{% for mail in mailSummaries %}
<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.
</blockquote>
{% endif %}
<form method="POST" action="/login">
<form method="POST" action="/">
<fieldset>
<label for="nameField">Name</label>
<input type="text" id="nameField" name="username" value="{{ username }}">
@ -27,7 +27,7 @@
</div>
<div class="buttons">
<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>
</fieldset>
</form>

View File

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

View File

@ -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) => {