godreams / admin-server

Web administration interface for Guardians of Dreams. http://godreams.org
3 stars 1 forks source link

Fix invite of existing user to a role, assign himself as related entity. #41

Open harigopal opened 7 years ago

harigopal commented 7 years ago

There's an issue that appears when users have multiple roles and were invited by different people.

Consider the following case:

  1. User is invited as Fellow by one NFP.
  2. User is invited as Coach by another Fellow.
  3. User invites a Volunteer to platform.
  4. When listing on VolunteersController#index, the new volunteer will not be listed because current_user_role is a Fellow, and since this user's Coach role is under another, the chain of relationships is broken.

Possible fix: When adding an existing user to another role, override default behaviour and:

  1. If new role is one step lower than current role, assign current role as parent.
  2. If new role is one step higher than current role, assign old role's parent as new one.
  3. If new role is two steps away, block it and demand that the intervening position be filled.

☝️ Haven't thought too much about this though - there might be holes in the logic.