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:
- Request header. Need to decide on a name for the header but you should be able to specify the organization in the request header.
- see use case: #432182 (comment 1765139828)
- Rails session
- First organization current user is a user of
Unauthenticated user(explore pages, etc):
- 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
- !140603 (comment 1714885494)
- https://docs.google.com/document/d/1W7QsQL_2wMLW9KJU5ZEZdyIqYtRC6_bwOoNXJUWNbiU/edit#heading=h.kwiw1svrp0if (internal link)
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