Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions controllers/makeProfileController.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,20 @@ exports.makeProfile = async (req, res, next) => {
try {
console.log("in the makeProfile controller")
const { id } = req.params;
const { name, email, githubLink, telegram, twitter, location, photo } = req.body; // get the new profile data from the request body
const { name, email, githubLink, telegramUsername, twitter, location, photo } = req.body; // get the new profile data from the request body


const user = await User.findById(id);
if (!user) {
return next(createError(404, 'User not found'));
}


user.name = name;
user.email = email;
user.githubLink = githubLink;
user.telegram = telegram;
user.telegramUsername = telegramUsername;
user.twitter = twitter;
user.location = location;
user.photo = photo;


const updatedUser = await user.save();

Expand Down
4 changes: 3 additions & 1 deletion models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ const userSchema = mongoose.Schema({
username: String,
password: String,
githubLink: String,
telegramUsername: String
telegramUsername: String,
twitter: String,
location: String,

})
module.exports = mongoose.model("User", userSchema);
2 changes: 1 addition & 1 deletion routes/projectRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const { makeProfile } = require("../controllers/makeProfileController");

router.get("/getprofile", authUser, getCurrentUser);
router.get("/getUserById/:id", getUserById);
router.post("/makeProfile/:id", makeProfile)
router.patch("/makeProfile/:id", makeProfile)

router.get("/allusers", getAllUsers);

Expand Down