Skip to content

Commit

Permalink
changed searchMentors api to public
Browse files Browse the repository at this point in the history
Change-Id: Ic136b0eabebd2e0f45de136404f312a3bfc09d65
  • Loading branch information
helloukey committed Jan 2, 2024
1 parent d41a190 commit 9f7e7f9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
8 changes: 6 additions & 2 deletions backend/controllers/matchController.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ const userRecommendations = async (req, res) => {

const searchMentors = async (req, res) => {
const { page, limit } = req.query;
const { _id } = req.user;

if (!page || !limit) {
return res.status(400).json({
Expand All @@ -226,11 +225,16 @@ const searchMentors = async (req, res) => {
});
}

// mentorIds
let mentorIds = [];

try {
let results = [];

// Get mentors Ids
const mentorIds = await getActiveMentorIds(_id);
if(req.user) {
mentorIds = await getActiveMentorIds(req.user._id);
}

// filter
const filter = constructExploreFilter(req.query, mentorIds);
Expand Down
27 changes: 18 additions & 9 deletions backend/routes/matches.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,27 @@ router.post(
// Search for mentors
router.get(
'/searchMentors',
passport.authenticate('jwt', { session: false }),
util.checkRole([role.mentee, role.admin]),
(req, res, next) => {
passport.authenticate('jwt', { session: false }, (err, user) => {
if (err || !user) return next();
req.user = user;
next();
})(req, res, next);
},
matchController.searchMentors,
);

// Search for mentors
router.get('/userRecommendations', (req, res, next) => {
passport.authenticate('jwt', { session: false }, (err, user) => {
if (err || !user) return next();
req.user = user;
next();
})(req, res, next);
}, matchController.userRecommendations);
router.get(
'/userRecommendations',
(req, res, next) => {
passport.authenticate('jwt', { session: false }, (err, user) => {
if (err || !user) return next();
req.user = user;
next();
})(req, res, next);
},
matchController.userRecommendations,
);

module.exports = router;

0 comments on commit 9f7e7f9

Please sign in to comment.