Skip to content

Commit 8e99952

Browse files
committed
clean fukaps
1 parent c268a44 commit 8e99952

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/server/chatInstances/usage.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,6 @@ export const getUserStatus = async (user: UserType, courseId: string) => {
132132

133133
if (!chatInstance) throw new Error('Chat instance not found')
134134

135-
console.log('chatInstance', chatInstance.toJSON())
136-
137135
// Get enrollment
138136
const enrollment = await Enrolment.findOne({
139137
where: {

src/server/routes/course.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,19 @@ courseRouter.get('/:id', async (req, res) => {
151151
include,
152152
})) as ChatInstance & { responsibilities: AcualResponsibility[] }
153153

154-
const canAccess =
154+
const hasFullAccess =
155155
user.isAdmin ||
156156
chatInstance.responsibilities.map((r) => r.user.id).includes(user.id)
157157

158-
if (!canAccess) throw new Error('Unauthorized')
158+
const objectToReturn = hasFullAccess
159+
? chatInstance
160+
: {
161+
...chatInstance.toJSON(),
162+
enrolments: undefined,
163+
responsibilities: undefined,
164+
}
159165

160-
return res.send(chatInstance)
166+
return res.send(objectToReturn)
161167
})
162168

163169
courseRouter.put('/:id', async (req, res) => {

0 commit comments

Comments
 (0)