Re-design routes
parent
df027310a8
commit
0c89b3c810
|
@ -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)
|
||||
|
|
|
@ -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}`)
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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">
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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) => {
|
||||
|
|
Loading…
Reference in New Issue