Multi‐Institute Backend Support - liferesearchapp/life-research-members-portal GitHub Wiki
Backend-Related Changes for Multi-Institute Support
With the expansion to support multiple institutes, significant changes have been made to how API calls are handled in the backend to ensure that data is contextually correct based on the selected institute.
urlIdentifier
with API Calls
Passing To ensure that all API requests are contextual to the currently selected institute, the urlIdentifier
is now passed as a query parameter with every call. This change helps in fetching or modifying data specific to an institute, maintaining data integrity and relevance.
Example of Fetching Products
When fetching products, the frontend first checks if an institute is selected. If found, it constructs a query parameter with the urlIdentifier
of the institute and includes it in the API request. Here's a brief overview of how this is implemented:
- Frontend Request: Constructs the query parameter based on the selected institute's
urlIdentifier
. - Authentication: An authentication header is added to ensure secure data transmission.
Backend Changes to Fetch Data
The backend has been adjusted to accept the urlIdentifier
from the query parameter and fetch data accordingly. Here’s how products are retrieved:
- Institute Identification: The backend first confirms the existence of the institute using the
urlIdentifier
. - Data Retrieval: Only the products associated with the identified institute are fetched.
Handling Non-existent Institutes
If no valid institute is found for the provided urlIdentifier
, an error is thrown, preventing any further actions and ensuring that operations do not proceed without proper context.
Conclusion
These changes ensure that the application correctly handles data operations across multiple institutes efficiently and securely. By passing the urlIdentifier
with each API call, the system maintains a high level of data accuracy and security tailored to each institute.
This methodology not only simplifies management but also enhances security and functionality, making the system robust against common multi-tenancy issues.