-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add shared attribute, add markshared mutation, add templateCour… #914
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good already!
You also need to adapt authorizations.ts
and mark the shared
attribute as public, it's not something we need to keep private.
And this could use an integration test where one instructor publishes a course, and then another instructor is able to find it (c.f. backend/integration-tests/07_course.ts Line 240 in fef1203
|
And we should also relax the check in backend/graphql/subcourse/mutations.ts Line 82 in fef1203
|
If I make the hasAccess method call conditional, the authorization method must not be @AuthorizedDeferred then right? |
Ah, true, we need two checks then. |
Hey Jonas, this got a bit confusing to me after a long break. May you please sum up which methods and auth checks should be changed? Thank you very much :) |
|
I see that there is a method call |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good, some minor touchups to be made then this is ready :)
graphql/subcourse/mutations.ts
Outdated
|
||
const student = await getSessionStudent(context, studentId); | ||
await prisma.subcourse_instructors_student.create({ data: { subcourseId: result.id, studentId: student.id } }); | ||
if (isCourseSharedOrOwned) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary if
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, you are right since I already throw an error in line 92 when the if condition isnt met :)
graphql/subcourse/mutations.ts
Outdated
}, | ||
}); | ||
const isCourseSharedOrOwned = !!courseInstructorAssociation || course.shared; | ||
if (!isCourseSharedOrOwned) { | ||
logger.error(`Subcourse(${courseId}) is not shared or Student(${studentId}) is not an instructor of this subcourse`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Subcourse -> Course
graphql/subcourse/mutations.ts
Outdated
@@ -71,7 +71,7 @@ class PublicLectureInput { | |||
@Resolver((of) => GraphQLModel.Subcourse) | |||
export class MutateSubcourseResolver { | |||
@Mutation((returns) => GraphQLModel.Subcourse) | |||
@AuthorizedDeferred(Role.ADMIN, Role.OWNER) | |||
@AuthorizedDeferred(Role.INSTRUCTOR) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, and this must be @Authorized
instead of @AuthorizedDeferred
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, overlooked this earlier
graphql/subcourse/mutations.ts
Outdated
const courseInstructorAssociation = await prisma.course_instructors_student.findFirst({ | ||
where: { | ||
courseId: courseId, | ||
studentId: studentId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, this for sure is wrong, we cannot trust our users to pass in their id. Please do
const student = await getSessionStudent(context, studentId);
... studentId: student.id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
apart from fixing the integration tests this should be good now
integration-tests/07_course.ts
Outdated
@@ -21,6 +22,7 @@ const courseOne = test('Create Course One', async () => { | |||
description: "Why should I test if my users can do that for me in production?" | |||
category: club | |||
allowContact: true | |||
shared: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need a separate mutation markShared afterwards
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please rephrase this comment? Do you mean that we need a separate test for shared and nonshared courses? For the current integration test I manually set the shared value to false. See line 414
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No the courseCreate Mutation does not take a shared attribute, thus the test is failing?
integration-tests/07_course.ts
Outdated
@@ -126,7 +129,7 @@ export const subcourseOne = test('Create Subcourse', async () => { | |||
allowChatContactProspects: true | |||
allowChatContactParticipants: true | |||
groupChatType: ${ChatType.NORMAL} | |||
}) { id } | |||
} studentId: ${student.userID}) { id } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and this can be reverted as we now use the session student
@Jonasdoubleyou or @realmayus Can you please have another look here? |
Um, the tests are still failing, have you seen my comment regarding shared: true? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
No description provided.