gathering / wannabe

Event-system for TG - wannabe.gathering.org
GNU General Public License v3.0
12 stars 7 forks source link

Add shared privacy filter utility (try 2) #69

Closed niccofyren closed 3 years ago

niccofyren commented 3 years ago

Tried to merge this, but while testing it in production it was just way to slow on main crew list page. There are a lot of access lookups, so no big surprise. I think we can probably improve this in at least a couple of ways:


While trying to add some basic profile picture privacy filters progress was halted since there wasn't a shared location for making sure user privacy preferences where taken into account.

This PR starts to gather the filters and logic we use when viewing user profile data of user Y as user X. For now this mostly matches existing implementations previously spread across different locations. But the idea is that we should extend it with other privacy options as needed, including hiding data of inactive users, users from other events, etc.

Relates to: https://github.com/gathering/wannabe/issues/20 Combines with https://github.com/gathering/wannabe/pull/65 to improve image privacy

Not quite sure how to test ApiController changes, so would be nice if some would verify that part

How it works

Any time you want to get a user object for use in a view (or other possible public facing location):

  1. Get user object as usual
  2. Pass it through $this->Acl->filterPrivateUserDetails($user) (or other way of accessing the ACL Component)
  3. The user object returned has been filtered based on user privacy preferences (such as hiding phone, email, etc) and the permissions of the viewing user (same crew, leader, superuser, etc).
  4. Use returned user as usual, but make sure to check if user properties are !empty (or similar) before accessing and outputing them