Skip to content

Commit

Permalink
Modify: Made upload of image during account creation compulsory
Browse files Browse the repository at this point in the history
  • Loading branch information
Shubham-Guptaji committed Apr 6, 2024
1 parent e780368 commit 0532113
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion controllers/blog.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ export const getHomeBlogs = asyncHandler(async function (req, res, next) {
$sort: { likes: -1 }, // Sort by likes (descending)
},
{
$limit: 2, // Limit to 6 documents
$limit: 6, // Limit to 6 documents
},
]),
User.find({ isClosed: false, isBlocked: false }, { _id: 1, username: 1, firstName: 1, lastName: 1, avatar: 1 })
Expand Down
5 changes: 3 additions & 2 deletions controllers/miscellaneous.controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ export const contactformHandler = asyncHandler(async function (req, res, next) {
// Save the new entry to the database
await newContact.save();
const newMessage = `
<h2>New Message Received</h2>
<h2>New Message Received at Alcodemy Blog</h2>
<p><b>Name: </b>${newContact.name}</p>
<p><b>Email: </b><a href="mailto:${newContact.email}">${newContact.email}</a></p>
<p><b>Subject: </b>${newContact.subject}<br/><i>${newContact.message}</i></p>
<p><b>Subject: </b>${newContact.subject}<br/></p>
<p><b>Message: </b><i>${newContact.message}</i></p>
`
sendEmail(process.env.CONTACT_US_EMAIL, subject, newMessage)

Expand Down
3 changes: 1 addition & 2 deletions controllers/user.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const registerUser = asyncHandler(async function (req, res, next) {
const { username, email, firstName, lastName, password } = req.body;

// Check if all the required fields are provided
if (!username || !email || !firstName || !lastName || !password) {
if (!username || !email || !firstName || !lastName || !password || !req.file) {
if (req.file) fs.rm(`uploads/${req.file.filename}`);
return next(new AppError("All fields are mandatory.", 400));
}
Expand Down Expand Up @@ -141,7 +141,6 @@ export const registerUser = asyncHandler(async function (req, res, next) {

// Generate a token for the logged-in user
const { accessToken, refreshToken } = await generateAccessAndRefreshTokens(user._id);

// Send a success response with the user's details
res
.status(201)
Expand Down

0 comments on commit 0532113

Please sign in to comment.