osu-capstone-cs72 / cs-applied-plan-portal

A portal that streamlines the planning process for OSU CS Applied students and advisors
https://applied-plan-portal.herokuapp.com
MIT License
2 stars 5 forks source link

Fix a role bug caused by out-of-date JWT payload setup #48

Closed philectron closed 4 years ago

philectron commented 4 years ago

Since the user's role has been removed from the JWT, the React server must fetch the authenticated user based on their ID every time to get the role.

There were still some portions of the React code that used .role or .userRole after getting the JWT, which invalidated the Advisor and Head Advisor roles because .role or .userRole is undefined and thus such elevated user got set back to the Student role instead of their designated role.

This bug is fixed in this PR. The new getProfile() function of the React code returns either an empty object {} or an object containing only the userId and the role, e.g. {userId: 123456, role: 2}.