diff --git a/Dockerfile b/Dockerfile index f3fcfd0..343c564 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:20 +FROM node:22 WORKDIR /usr/src/app COPY package*.json ./ RUN npm install --only=production diff --git a/README.md b/README.md index cf3ec38..8ecb075 100644 --- a/README.md +++ b/README.md @@ -60,3 +60,7 @@ You can also use Docker to self-host pontus-mail's frontend. Make sure you have ``` You will now have a fully functioning Node.js Express server, which will be running on the port specified in `docker-compose.yml`, and internally on port `3000`. + +# To-Do +- [ ] Port to NextJS? +- [ ] Hovering effects for buttons \ No newline at end of file diff --git a/app.js b/app.js index 7e2c641..b401938 100644 --- a/app.js +++ b/app.js @@ -4,7 +4,6 @@ const path = require('path'); const fs = require('fs'); const session = require('express-session'); const { Sequelize, DataTypes } = require('sequelize'); -const { error } = require('console'); require('dotenv').config(); const app = express(); @@ -101,12 +100,15 @@ app.get('/register', (req, res) => { app.post('/register', async (req, res) => { const { fullName, email, reason, telegram } = req.body; + const crit = /^[a-zA-Z0-9.-]+$/; // regex (see also: public/js/register.js) + if (!crit.test(email) || /\s/.test(email) || email !== email.toLowerCase()) { + return res.render('error/500'); + } await Request.create({ fullName, email, reason, telegram }); res.render('reg-success', { currentPage: 'register' }); }); app.get('/request', async (req, res) => { - console.log("Got /request"); const { email } = req.query; if (!email) { @@ -167,6 +169,7 @@ app.post('/admin/delete-request', checkAdminAuth, async (req, res) => { res.redirect('/admin/dashboard'); }); +// Start server on 3000 app.listen(3000, () => { console.log('Server started on port 3000'); }); \ No newline at end of file diff --git a/public/js/donate.js b/public/js/donate.js index cd6505e..5a88c6b 100644 --- a/public/js/donate.js +++ b/public/js/donate.js @@ -1,8 +1,8 @@ function copyToClipboard(elementId) { - const text = document.getElementById(elementId).innerText; - navigator.clipboard.writeText(text).then(() => { - alert('Copied to clipboard'); - }).catch(err => { - console.error('Failed to copy: ', err); - }); + const text = document.getElementById(elementId).innerText; + navigator.clipboard.writeText(text).then(() => { + alert('Copied to clipboard'); + }).catch(err => { + console.error('Failed to copy: ', err); + }); } \ No newline at end of file diff --git a/public/js/register.js b/public/js/register.js new file mode 100644 index 0000000..f61e3b5 --- /dev/null +++ b/public/js/register.js @@ -0,0 +1,9 @@ +function validateEmail() { + const email = document.getElementById('email').value; + const regex = /^[a-zA-Z0-9.-]+$/; + if (!regex.test(email)) { + alert('An invalid email has been entered. You may only include letters, numbers, periods, and dashes. Make sure you do not include @p0ntus.com'); + return false; + } + return true; +} \ No newline at end of file diff --git a/src/error/404.ejs b/src/error/404.ejs index 42efbf6..5f7ee56 100644 --- a/src/error/404.ejs +++ b/src/error/404.ejs @@ -1,4 +1,4 @@ -<%- include('../shards/header', { title: '404 Not Found - p0ntus mail' }) %> +<%- include('../shards/header', { title: '404 Not Found - p0ntus mail', currentPage: 'err' }) %>
404 Not Found
diff --git a/src/error/500.ejs b/src/error/500.ejs index f7ee2bd..3221398 100644 --- a/src/error/500.ejs +++ b/src/error/500.ejs @@ -1,4 +1,4 @@ -<%- include('../shards/header', { title: '500 Internal Server Error - p0ntus mail' }) %> +<%- include('../shards/header', { title: '500 Internal Server Error - p0ntus mail', currentPage: 'err' }) %>
500 Internal Server Error
diff --git a/src/error/email.ejs b/src/error/email.ejs index d27b1f5..4a503c3 100644 --- a/src/error/email.ejs +++ b/src/error/email.ejs @@ -1,4 +1,4 @@ -<%- include('../shards/header', { title: 'Request Status - p0ntus mail' }) %> +<%- include('../shards/header', { title: 'Request Status - p0ntus mail', currentPage: 'err' }) %>
We need your email
diff --git a/src/register.ejs b/src/register.ejs index 023140d..4231880 100644 --- a/src/register.ejs +++ b/src/register.ejs @@ -10,26 +10,33 @@
If you haven't filled out a registration request -

Do not use this service for spam. It is a waste of your time. I have added protections to prevent spam, including sending quotas per hour. I will catch you before you can send a good enough amount.


-
-
- +

Do not use this service for spam. It is a waste of your time. I have added protections to prevent spam, including sending quotas per hour. I will catch you before you can send a good enough amount.

+ +
+
-
- - +
+ +
+ +
+ @p0ntus.com +
+
+ Only letters, numbers, periods, and dashes are allowed.
-
- +
+
-
- - +
+ +
- +
+ <%- include('shards/footer') %> \ No newline at end of file