mirror of
https://github.com/Crazyco-xyz/48hr.email.git
synced 2025-06-30 22:17:09 +02:00
- Conversion function updates: - Enabling conversion now rounds to the nearest max. value where `i > 1`, and if rounding was needed it will create a Tooltip displaying the config value on hover. - If rounding wasnt needed, or conversion is disabled in the config then no tooltip will be created, to avoid confusion. - Updated footer: - Created new function called footerbuilder() - The config value is now always underlined and italic to make it more obvious you can (if rounded) "interact" with it.
57 lines
1.4 KiB
JavaScript
57 lines
1.4 KiB
JavaScript
const router = new express.Router()
|
|
const express = require('express')
|
|
const {check, validationResult} = require('express-validator')
|
|
|
|
const randomWord = require('random-word')
|
|
const config = require('../../../application/config')
|
|
const Helper = require('../../../application/helper')
|
|
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: config.email.domains,
|
|
branding: config.http.branding,
|
|
})
|
|
})
|
|
|
|
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(
|
|
'/',
|
|
[
|
|
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(),
|
|
branding: config.http.branding,
|
|
})
|
|
}
|
|
|
|
res.redirect(`/inbox/${req.body.username}@${req.body.domain}`)
|
|
}
|
|
)
|
|
|
|
module.exports = router
|