Skip to content

Commit

Permalink
lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
holabayor committed Sep 23, 2023
1 parent 7d90ecb commit 2bdd6ab
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions controllers/authController.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,28 @@ const User = require('../models/user.model');
const { createCustomError } = require('../errors/custom-errors');
const Organization = require('../models/organization.model');
const OrgLunchWallet = require('../models/org_lunch_wallet.model');
const {sendEmail} = require('./mailController')
const { sendEmail } = require('./mailController');

const secretKey = process.env.JWT_SECRET_KEY;

async function validateEmail(req, res, next) {
try {
const email = req.body.email;
const { email } = req.body;
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;

if (!emailRegex.test(email)) {
throw createCustomError('Invalid email format', 400);
}

await sendEmail(email);

next();
} catch (error) {
console.error(`Error sending email: ${error.message}`);
next(createCustomError('Invalid email', 400));
}
}



async function createUser(req, res, next) {
try {
const {
Expand Down Expand Up @@ -231,4 +230,10 @@ async function createOrgAndUser(req, res, next) {
}
}

module.exports = { validateEmail, createUser, loginUser, logoutUser, createOrgAndUser };
module.exports = {
validateEmail,
createUser,
loginUser,
logoutUser,
createOrgAndUser,
};

0 comments on commit 2bdd6ab

Please sign in to comment.