wanderlust icon indicating copy to clipboard operation
wanderlust copied to clipboard

[FEATURE] : Add Profile Page which shows user details and No. of Blog Post by User

Open Adityajparmar37 opened this issue 8 months ago • 5 comments

Description

Having a Profile Page is good option. As it is very usefully to know user itself details and can know total how many number of post user has made .

Use Case

1 ) Able to know user basic details like username and email 2 ) Able to change/Update password 3 ) Able to look over how many number of Blog post user has done

Additionally able to

4 ) Perform CRUD operation over the blog user has post if possible

This will uplift your website.

Proposed Solution

1 ) As soon as user login/sign-in the website then added the user details to Local Storage of Browser. 2 ) Take the User details from Local Storage and show it as Profile Page 3 ) Create 1 API which take all information of User and check if any information has been change by user then update the user details in DB . 4 ) Create another API which take user email or username and find the user Blog post details form DB and fetch it . Then Show the details of user ' s blog post.

Eg. router.put( "/update", authMid, handler(async (req, res, next) => { try { const formData = req.body; const userId = req.user.id; const existingProfile = await Model.findById(userId);

  // Check if password is provided and update it
  if (formData.password) {
    const salt = await bcrypt.genSalt(10);
    formData.password = await bcrypt.hash(
      formData.password,
      salt
    );
  }

  // Update the user profile with the new data
  const updatedProfile =
    await Model.findByIdAndUpdate(
      userId,
      formData,
      { new: true }
    );

  res.json({
    updatedProfile,
    update: true,
  });
} catch (error) {
  console.log(error);
  next(error);
}

}) );

5 ) Additional can create 2 API . 1st to Delete the blog post by user . 2nd Updating the blog post.

Additional Information

Hope you find issue to be good to solve

Attachments

image

Adityajparmar37 avatar Jun 03 '24 05:06 Adityajparmar37