Skip to content

Set Current organization on requests

Background

We need a way to keep track of the current organization and to switch organizations. There has been discussion about this in the grouptenant scale group sync (internal link) and in #437092 (closed)

Proposal

Calculating current organization

For every request we should calculate the current organization with the follow in this order:

Authenticated user:

  1. Request header. Need to decide on a name for the header but you should be able to specify the organization in the request header.
  2. Rails session
  3. First organization current user is a user of

Unauthenticated user(explore pages, etc):

  1. Default organization(means it will be on the primary cell)

The current organization should be exposed to the backend via the current_organization method and exposed to the frontend via gon.

Relevant discussion

Plan

  • Implement basic middleware for setting of the current organization - !143978 (merged)
  • Add qualifications for authenticated vs unauthenticated requests - !144811 (merged)
Edited by Doug Stull