Skip to content

Commit

Permalink
user profile fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
singharaj-usai committed Oct 16, 2024
1 parent 19e3249 commit 22edc4c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions server/functions/api/routes/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const User = require('../models/User');
router.get('/user/:username', authenticateToken, async (req, res) => {
try {
const { username } = req.params;
const currentUser = await User.findOne(req.user.userId);
const currentUser = await User.findOne({ userId: req.user.userId });
const user = await User.findOne({ username }).select(
'username userId signupDate lastLoggedIn blurb friendRequests friends sentFriendRequests'
);
Expand All @@ -16,9 +16,9 @@ router.get('/user/:username', authenticateToken, async (req, res) => {
return res.status(404).json({ error: 'User not found' });
}

const isFriend = currentUser.friends.includes(user._id);
const friendRequestSent = user.friendRequests.includes(currentUser._id);
const friendRequestReceived = currentUser.friendRequests.includes(user._id);
const isFriend = currentUser.friends.includes(user.userId);
const friendRequestSent = user.friendRequests.includes(currentUser.userId);
const friendRequestReceived = currentUser.friendRequests.includes(user.userId);

const userObject = user.toObject();
delete userObject.friendRequests;
Expand Down

0 comments on commit 22edc4c

Please sign in to comment.