From 548064782e8c11647053200fb69b6e0d42e5b55e Mon Sep 17 00:00:00 2001 From: BIG2EYEZ Date: Sun, 28 Jan 2024 00:09:22 +0800 Subject: [PATCH] clean up --- Sean/modules/nodeMailer.js | 4 ++- Sean/modules/otpUtils.js | 6 +++- Sean/modules/rateLimitMiddleware.js | 4 +++ Sean/modules/validationMiddleware.js | 6 ++-- Sean/views/index.ejs | 42 ++-------------------------- 5 files changed, 19 insertions(+), 43 deletions(-) diff --git a/Sean/modules/nodeMailer.js b/Sean/modules/nodeMailer.js index 45ac730..ccae59f 100644 --- a/Sean/modules/nodeMailer.js +++ b/Sean/modules/nodeMailer.js @@ -13,4 +13,6 @@ let transporter = nodemailer.createTransport({ pass: process.env.epass }, }); -module.exports = { transporter }; \ No newline at end of file +module.exports = { transporter }; + + diff --git a/Sean/modules/otpUtils.js b/Sean/modules/otpUtils.js index c824c5b..5d6edbd 100644 --- a/Sean/modules/otpUtils.js +++ b/Sean/modules/otpUtils.js @@ -39,4 +39,8 @@ const sendOTPByEmail = async (email, otp) => { module.exports = { generateOTP, sendOTPByEmail - }; \ No newline at end of file + }; + + + + \ No newline at end of file diff --git a/Sean/modules/rateLimitMiddleware.js b/Sean/modules/rateLimitMiddleware.js index 1f0c2b9..b562538 100644 --- a/Sean/modules/rateLimitMiddleware.js +++ b/Sean/modules/rateLimitMiddleware.js @@ -4,6 +4,10 @@ const limiter = rateLimit({ windowMs: 15 * 60 * 1000, // 15 minutes max: 5, // limit each IP to 5 requests per windowMs message: 'Too many login attempts from this IP, please try again later.', + standardHeaders: "draft-7", // draft-6: `RateLimit-*` headers; draft-7: combined `RateLimit` header + legacyHeaders: false, // Disable the `X-RateLimit-*` headers. }); module.exports = limiter; + + diff --git a/Sean/modules/validationMiddleware.js b/Sean/modules/validationMiddleware.js index 81b8606..4557937 100644 --- a/Sean/modules/validationMiddleware.js +++ b/Sean/modules/validationMiddleware.js @@ -1,4 +1,4 @@ -const { validationResult, body } = require('express-validator'); +const {body } = require('express-validator'); const locationValidation = [ body('name').trim().isLength({ min: 1 }).withMessage('Name must not be empty').escape(), @@ -63,7 +63,7 @@ const createValidation = [ body('name').trim().isLength({ min: 1 }).withMessage('Name must not be empty').escape(), body('username').trim().isLength({ min: 1 }).withMessage('Username must not be empty').escape(), body('email').isEmail().withMessage('Invalid email address').normalizeEmail(), - body('password').custom((value) => { + body('password').escape().trim().custom((value) => { if (!isStrongPassword(value)) { throw new Error('Password does not meet complexity requirements'); } return true; }), body('jobTitle').trim().isLength({ min: 1 }).withMessage('Job title must not be empty').escape(), @@ -102,3 +102,5 @@ module.exports = { ,sensorValidation,sensorupdateValidation,sensordeleteValidation,loginValidation,otpValidation ,createValidation }; + + diff --git a/Sean/views/index.ejs b/Sean/views/index.ejs index e3d14b4..c3aa965 100644 --- a/Sean/views/index.ejs +++ b/Sean/views/index.ejs @@ -7,8 +7,6 @@ - - Home @@ -21,16 +19,9 @@ - - - - -
- - - -
@@ -133,11 +120,6 @@
- - - - -
@@ -156,16 +138,12 @@
- - -

Contacts

-
@@ -185,27 +163,14 @@
-
- - - - -
- - -
- +

AI Website Builder
- - - \ No newline at end of file + +