Skip to content

Rest cleanup

Alex requested to merge rest-user-cleanup into master

Part of !910 (closed) Should be merged simultaneously with foodsharing-android!202 (merged) and the next App release.

What does this MR do?

Unifies the user rest controllers by moving the /profile/current function from ProfileRestController to /user/current/profile in UserRestController. There are now the following functions:

  • /user/{id} accessible to all logged in users. Returns name,id,avatar,sleep_status
  • /user/current as an alias for the above
  • /user/{id}/details accessible to the user itself and orga. Returns the whole profile.
  • /user/current/details again as an alias

The normalisation class now contains normalizeUser for the short info (id, name, sleep status, avatar) and normalizeUserDetails for the whole profile.

This also adds a UserPermissions class for the mentioned permission checks.

How confident are you it won't break things if deployed?

Very sure concerning the website, because this only affects the login. The app would break with this and would need an immediate update because it still uses beta as backend:

  • Rename name to firstname
  • Use new /user/current/profile endpoint
  • /user/current now returns 401 instead of 404 if not logged in

How to test

  1. Checkout branch locally
  2. Login as foodsaver

Checklist

  • added a test, or explain why one is not needed/possible...
  • no unrelated changes
  • asked someone for a code review
  • joined #foodsharing-beta channel at https://slackin.yunity.org
  • added an entry to CHANGELOG.md (description, merge request link, username(s))
  • Once your MR has been merged, you are responsible to update the #foodsharing-beta Slack channel about what has been changed here. They will test your work in different browsers, roles or other settings
Edited by Alex

Merge request reports