This commit is contained in:
BIG2EYEZ
2024-01-28 00:09:22 +08:00
parent 6190cb63cd
commit 548064782e
5 changed files with 19 additions and 43 deletions

View File

@ -13,4 +13,6 @@ let transporter = nodemailer.createTransport({
pass: process.env.epass
},
});
module.exports = { transporter };
module.exports = { transporter };

View File

@ -39,4 +39,8 @@ const sendOTPByEmail = async (email, otp) => {
module.exports = {
generateOTP,
sendOTPByEmail
};
};

View File

@ -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;

View File

@ -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
};