associateassessmentuid()
associateassessmentuid
Function Name
associateassessmentuid
Trigger
This Cloud Function is triggered by a direct call (onCall). It expects to be invoked typically through a client-side request within your application.
Inputs
The function expects a JSON payload containing the following keys:
- adminUid: A string that represents the unique identifier of an administrator. This UID is intended to specify which administrator is performing the operation or whose data is being accessed or modified.
- assessmentUid: A string that represents the unique identifier of an assessment. This UID is used to associate a specific assessment with an administrator.
Example JSON input:
{
"adminUid": "admin123",
"assessmentUid": "assessment456"
}
Outputs
The function returns the result of the associateAssessmentUid
operation. This output can be:
- A success message or object indicating that the association was successfully created or updated.
- An error message or object indicating that the operation failed, which may include reasons for the failure (e.g., invalid UIDs, permission issues, database errors).
Description
The associateassessmentuid
function is designed to create or update the association between a user's authentication UID in the "admin" and "assessment" Firebase projects. This is part of managing access to ROAR two separate Firebase projects: gse-roar-admin
and gse-roar-assessment
. The function takes the UIDs for both admin and assessment projects and updates relevant records in the database.
Error Handling
This function should include error handling to manage and log various failure scenarios, such as:
- Non-existent
adminUid
orassessmentUid
- Database connection issues
- Permission errors if the requestor does not have the right to associate these UIDs
- Any unexpected exceptions
Errors should be logged appropriately and, where feasible, detailed error information should be returned to the caller to facilitate troubleshooting without exposing sensitive system details.
Security Considerations
- Authentication: The function checks that the request is made by an authenticated user.
- Authorization: The function should verify that the requester has the appropriate administrative rights to associate an administrator UID with an assessment UID.
- Data Validation: Ensure that both
adminUid
andassessmentUid
are valid and formatted correctly before attempting any operations with them.
Deployment
This function is deployed automatically using GitHub actions, whenever changes are merged into the main
branch.