Skip to content

S25 staff schedule error fix: #2656#2657

Open
woobenskyp wants to merge 5 commits intodevelopfrom
s25-staff-schedule-error
Open

S25 staff schedule error fix: #2656#2657
woobenskyp wants to merge 5 commits intodevelopfrom
s25-staff-schedule-error

Conversation

@woobenskyp
Copy link
Contributor

Fix: #2656

The implemented fix in this pull request is to check whether the person is a staff member (not faculty) as a condition to building the schedule section.
I also added a catch for the initial network error that was causing the constant spinning. The server sends a 401 authorization error if the profile being viewed isn't faculty or student. The catch will set the loading to false.

Copy link
Contributor

@EjPlatzer EjPlatzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! I see a few issues with your changes, which is not really your fault because you're working around logic that is wrong in the backend.

)}

{(myProf || !profileIsStudent || canReadStudentSchedules) && (
{(myProf || (!profileIsStudent && !profileIsStaff) || canReadStudentSchedules) && ( // is it only faculty that have schedule? could we say if faculty instead here?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fixing a poor backend authorization strategy with a workaround in the frontend. The better fix would be to improve the auth strategy in the backend. See, for example, my changes to StateYourBusiness.cs in my schedule-quad branch for the API. That is a good start, but probably still not sufficient.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. Is this the branch that was fixing the quad issue? should we continue this solution?

const viewerIsPolice = useAuthGroups(AuthGroup.Police);
const [canReadStudentSchedules, setCanReadStudentSchedules] = useState<boolean>();
const profileIsStudent = profile.PersonType?.includes('stu');
const profileIsStaff = profile.Type == 'Staff'; // should we create an dict enum of the possible values?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The profile.Type field is not a reliable indicator of a person's status at Gordon, sadly. For one thing, the same person can at the same time be both staff and student (or equally faculty and student). Also, people who are officially staff can teach courses, in which case their course schedule should be visible to students.

I think, rather than trying to work around this complexity in the frontend, we should clean up the logic in the backend. I think the ideal logic would be something like:

  1. Anyone can view their own course schedule without limitations
  2. Faculty (and potentially a couple special categories of staff such as Staff Advisors) can view students' course schedules
  3. Any (authenticated) user can view a person's instructor schedule - i.e. a schedule that only shows the courses where a person is an instructor, and not a student. This handles the case where a person is both a student and an instructor, since their student course schedule shouldn't be visible to other students, but their instructor schedule should be.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you suggest working on the authentication issue in its own branch or continuing the work you had in the schedule-quad branch?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good question. I think if you want to implement the third point in my original comment, you should probably continue work in my schedule-quad branch (and the corresponding schedule-quad-fixes branch for the UI.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking into the branch, it is 513 commits behind develop, which would make it challenging to perform a clean merge (will definitely be easier later with more familiarity with the code). Maybe a rework of the solution from develop could be easier?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it will probably be easier to start fresh on the latest develop. Normally, that wouldn't be such an issue since you can simply rebase the commits, but there have been some really big formatting and whitespace changes in the interim, which git struggles with.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For option 3 in the authorization logic, the way the process is currently set up--checking for authorization for the getAllCourses action-- makes it a little complicated to only give access to Instructor courses.
I wonder if it would be a good solution to handle this in the controller--to check who is requesting all the courses and if it is a student to only return instructor courses for that profile. otherwise return all of them.
maybe a getAllInstructorCourses could be added in the service.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that would work. Except I would say, if the requestor is a faculty/staff member, return all courses, otherwise return only instructor courses.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay. sounds good! Is it an issue if all faculty can see classes that a faculty or staff is taking?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I don't think so. It's part of faculty's job to see student's course schedules, and just because someone is a faculty or staff member doesn't mean they're not also a student.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
We are trying to recover the updates we made in Terms last week from the VM. Could we merge this current solution to the permisions and quad issues? I can work on the Terms vs sessions in a different pull Request.

setLoading(false);
console.log(profile);
})
.catch((reason: AuthError) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This AuthError comes from Microsoft's Authentication library, and is unrelated to authorization errors thrown by the backend.

allSessionSchedules[0];
setSelectedSchedule(defaultSchedule);
setLoading(false);
console.log(profile);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future reference, pull requests should not have any leftover console.logs.

@Centerville1 Centerville1 added the s25 Summer Practicum 2025 label Jun 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

s25 Summer Practicum 2025

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Staff member without schedule causes continuous spinning in Class Schedule section

4 participants