ucfopen / Materia

Engage students with easily embedded apps for online courses. Supercharge your course with compelling experiences and game mechanics.
https://ucfopen.github.io/Materia-Docs/
GNU Affero General Public License v3.0
36 stars 32 forks source link

API Error Response Overhaul #1526

Closed clpetersonucf closed 3 weeks ago

clpetersonucf commented 10 months ago

Many API endpoints return a boilerplate error message if certain conditions aren't met, chiefly whether the current user is logged in and their session is valid. These are largely producing responses in the form of Msg::no_login(), which returns a seemingly successful response with an error message - yuck.

Unfortunately, a lot of our recent tooling of the front-end means these API responses aren't being handled appropriately. Ideally, an error response performs the following:

  1. Returns an appropriate response code (not 200!)
  2. Unloads and destroys the session, if it wasn't done so already and the action is appropriate (e.g., no login)
  3. Returns an appropriate response message

1525 already begins the work of better handling invalidLogin states but other parts of the front-end do not behave well when a seemingly successful API response doesn't actually include expected payload data, like any React Query onError hooks.

clpetersonucf commented 3 weeks ago

Completed in #1547 as part of 10.2.0 💪