mirror of
https://github.com/Crazyco-xyz/48hr.email.git
synced 2025-12-14 13:56:32 +01:00
automatically generate example inbox url
This commit is contained in:
parent
e158fac414
commit
9d991486ae
3 changed files with 36 additions and 36 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
const express = require('express')
|
const express = require('express')
|
||||||
const router = new express.Router()
|
const router = new express.Router()
|
||||||
const {check, validationResult} = require('express-validator')
|
const { check, validationResult } = require('express-validator')
|
||||||
|
|
||||||
const randomWord = require('random-word')
|
const randomWord = require('random-word')
|
||||||
const config = require('../../../application/config')
|
const config = require('../../../application/config')
|
||||||
|
|
@ -10,49 +10,49 @@ const helper = new(Helper)
|
||||||
const purgeTime = helper.purgeTimeElemetBuilder()
|
const purgeTime = helper.purgeTimeElemetBuilder()
|
||||||
|
|
||||||
router.get('/', (req, res, _next) => {
|
router.get('/', (req, res, _next) => {
|
||||||
res.render('login', {
|
res.render('login', {
|
||||||
title: `${config.http.branding[0]} | Your temporary Inbox`,
|
title: `${config.http.branding[0]} | Your temporary Inbox`,
|
||||||
username: randomWord(),
|
username: randomWord(),
|
||||||
purgeTime: purgeTime,
|
purgeTime: purgeTime,
|
||||||
domains: helper.getDomains(),
|
domains: helper.getDomains(),
|
||||||
branding: config.http.branding,
|
branding: config.http.branding,
|
||||||
})
|
example: config.email.examples.account,
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
router.get('/inbox/random', (req, res, _next) => {
|
router.get('/inbox/random', (req, res, _next) => {
|
||||||
res.redirect(`/inbox/${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) => {
|
router.get('/logout', (req, res, _next) => {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If we ever need a logout sequence, now we can have one!
|
* If we ever need a logout sequence, now we can have one!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
res.redirect('/')
|
res.redirect('/')
|
||||||
})
|
})
|
||||||
|
|
||||||
router.post(
|
router.post(
|
||||||
'/',
|
'/', [
|
||||||
[
|
check('username').isLength({ min: 1 }),
|
||||||
check('username').isLength({min: 1}),
|
check('domain').isIn(config.email.domains)
|
||||||
check('domain').isIn(config.email.domains)
|
],
|
||||||
],
|
(req, res) => {
|
||||||
(req, res) => {
|
const errors = validationResult(req)
|
||||||
const errors = validationResult(req)
|
if (!errors.isEmpty()) {
|
||||||
if (!errors.isEmpty()) {
|
return res.render('login', {
|
||||||
return res.render('login', {
|
userInputError: true,
|
||||||
userInputError: true,
|
title: `${config.http.branding[0]} | Your temporary Inbox`,
|
||||||
title: `${config.http.branding[0]} | Your temporary Inbox`,
|
purgeTime: purgeTime,
|
||||||
purgeTime: purgeTime,
|
username: randomWord(),
|
||||||
username: randomWord(),
|
domains: helper.getDomains(),
|
||||||
domains: helper.getDomains(),
|
branding: config.http.branding,
|
||||||
branding: config.http.branding,
|
})
|
||||||
})
|
}
|
||||||
}
|
|
||||||
|
|
||||||
res.redirect(`/inbox/${req.body.username}@${req.body.domain}`)
|
res.redirect(`/inbox/${req.body.username}@${req.body.domain}`)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
module.exports = router
|
module.exports = router
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
{% block body %}
|
{% block body %}
|
||||||
|
|
||||||
<div style="float: right; text-align: end;">
|
<div style="float: right; text-align: end;">
|
||||||
<a href="/inbox/example@48hr.email">Example Inbox</a>
|
<a href="/inbox/{{ example }}">Example Inbox</a>
|
||||||
</div>
|
</div>
|
||||||
<div id="login">
|
<div id="login">
|
||||||
<h1>Welcome!</h1>
|
<h1>Welcome!</h1>
|
||||||
|
|
|
||||||
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "48hr.email",
|
"name": "48hr.email",
|
||||||
"version": "1.5.4",
|
"version": "1.6.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "48hr.email",
|
"name": "48hr.email",
|
||||||
"version": "1.5.4",
|
"version": "1.6.1",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"array.prototype.flatmap": "^1.3.2",
|
"array.prototype.flatmap": "^1.3.2",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue