Skip to content

Commit c862f70

Browse files
authored
fix: takes passport's user name instead of the one passed in frontend (#405)
1 parent 2b697d8 commit c862f70

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

api/src/controllers/reviews.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ router.get('/', async function (req, res, next) {
134134
router.post('/', async function (req, res, next) {
135135
if (req.session.passport) {
136136
//^ this should be a middleware check smh
137-
console.log('Adding Review:', req.body);
138137

139138
// check if user is trusted
140139
const reviewsCollection = await getCollection(COLLECTION_NAMES.REVIEWS);
@@ -165,6 +164,9 @@ router.post('/', async function (req, res, next) {
165164
if (reviews?.length > 0)
166165
return res.status(400).json({ error: 'Review already exists for this professor and course!' });
167166
// add review to mongo
167+
req.body.userDisplay =
168+
req.body.userDisplay === 'Anonymous Peter' ? 'Anonymous Peter' : req.session.passport.user.name;
169+
req.body.userID = req.session.passport.user.id;
168170
await addDocument(COLLECTION_NAMES.REVIEWS, req.body);
169171

170172
// echo back body

0 commit comments

Comments
 (0)