implement display download and filter api logs
This commit is contained in:
@ -1,12 +1,13 @@
|
||||
const nodemailer = require("nodemailer");
|
||||
const otpGenerator = require('otp-generator');
|
||||
const path = require('path')
|
||||
const path = require('path');
|
||||
require('dotenv').config({ path: path.resolve(__dirname, '../.env') })
|
||||
|
||||
const generateOTP = () => {
|
||||
const otp = otpGenerator.generate(6, { upperCase: false, specialChars: false });
|
||||
const otp = otpGenerator.generate(8, { upperCase: true, specialChars: true });
|
||||
const expirationTime = Date.now() + 5 * 60 * 1000; // 5 minutes expiration
|
||||
return { otp, expirationTime };
|
||||
|
||||
};
|
||||
const sendOTPByEmail = async (email, otp) => {
|
||||
try {
|
||||
|
@ -20,7 +20,7 @@ const locationdeleteValidation = [
|
||||
const sensorValidation = [
|
||||
body('sensorname').trim().isLength({ min: 1 }).withMessage('Sensor Name must not be empty').escape(),
|
||||
body('added_by').trim().isLength({ min: 1 }).withMessage('Added by must not be empty').escape(),
|
||||
body('macAddress').custom(value => {
|
||||
body('macAddress').escape().custom(value => {
|
||||
const macAddressRegex = /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/;
|
||||
if (!macAddressRegex.test(value)) {
|
||||
throw new Error('Invalid MAC address format');
|
||||
@ -35,7 +35,7 @@ const sensorupdateValidation = [
|
||||
body('id').trim().escape(),
|
||||
body('sensorname').trim().isLength({ min: 1 }).withMessage('Sensor Name must not be empty').escape(),
|
||||
body('added_by').trim().isLength({ min: 1 }).withMessage('Added by must not be empty').escape(),
|
||||
body('macAddress').custom(value => {
|
||||
body('macAddress').escape().custom(value => {
|
||||
const macAddressRegex = /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/;
|
||||
if (!macAddressRegex.test(value)) {
|
||||
throw new Error('Invalid MAC address format');
|
||||
|
Reference in New Issue
Block a user